Browse Source

Replace TestSourcesPlugin with Gradle test fixture support

Prior to this series of commits, the Spring Framework build used a
custom TestSourcesPlugin to share test utilities and fixtures between
projects. This plugin served its purpose; however, it also had its
drawbacks:

- All test code was visible in all other (downstream) projects, and that
  made it too easy to introduce unnecessary coupling. For example,
  this made it more difficult to migrate to JUnit Jupiter.

This commit addresses such issues by migrating to Gradle's first-class
support for "Java test fixtures".

- Having test fixture code in a dedicated source folder makes it
  readily apparent that the code is reused across the test suite.
- The build is now much cleaner since projects explicitly declare that
  they rely on specific test fixtures of upstream projects.
- Incremental builds are now much faster on average since downstream
  projects no longer have to be recompiled due to changes in tests in
  upstream projects.
- Prior to these commits we effectively had around 20 test fixture
  dependencies. With these commits we effectively now have only 7 test
  fixture dependencies (i.e., projects that share test fixtures).

Closes gh-23550
pull/24287/head
Sam Brannen 6 years ago
parent
commit
3aa2605fda
  1. 1
      build.gradle
  2. 16
      buildSrc/README.md
  3. 4
      buildSrc/build.gradle
  4. 95
      buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java
  5. 9
      gradle/spring-module.gradle
  6. 6
      integration-tests/integration-tests.gradle
  7. 6
      integration-tests/src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests.java
  8. 10
      integration-tests/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java
  9. 6
      integration-tests/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java
  10. 2
      integration-tests/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementIntegrationTests.java
  11. 8
      integration-tests/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests-context.xml
  12. 14
      integration-tests/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests-context.xml
  13. 3
      spring-aop/spring-aop.gradle
  14. 26
      spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutTests.java
  15. 2
      spring-aop/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutMatchingTests.java
  16. 4
      spring-aop/src/test/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPointTests.java
  17. 4
      spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJExpressionPointcutTests.java
  18. 28
      spring-aop/src/test/java/org/springframework/aop/aspectj/TypePatternClassFilterTests.java
  19. 8
      spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java
  20. 4
      spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/ArgumentBindingTests.java
  21. 2
      spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJPointcutAdvisorTests.java
  22. 2
      spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java
  23. 2
      spring-aop/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJNamespaceHandlerTests.java
  24. 4
      spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java
  25. 2
      spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java
  26. 2
      spring-aop/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java
  27. 4
      spring-aop/src/test/java/org/springframework/aop/framework/AopProxyUtilsTests.java
  28. 4
      spring-aop/src/test/java/org/springframework/aop/framework/IntroductionBenchmarkTests.java
  29. 2
      spring-aop/src/test/java/org/springframework/aop/framework/MethodInvocationTests.java
  30. 2
      spring-aop/src/test/java/org/springframework/aop/framework/PrototypeTargetTests.java
  31. 38
      spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java
  32. 24
      spring-aop/src/test/java/org/springframework/aop/framework/adapter/ThrowsAdviceInterceptorTests.java
  33. 8
      spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java
  34. 4
      spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeBeanNameAdvisorsTests.java
  35. 6
      spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java
  36. 2
      spring-aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java
  37. 4
      spring-aop/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java
  38. 6
      spring-aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java
  39. 4
      spring-aop/src/test/java/org/springframework/aop/support/ClassFiltersTests.java
  40. 2
      spring-aop/src/test/java/org/springframework/aop/support/ClassUtilsTests.java
  41. 2
      spring-aop/src/test/java/org/springframework/aop/support/ComposablePointcutTests.java
  42. 6
      spring-aop/src/test/java/org/springframework/aop/support/ControlFlowPointcutTests.java
  43. 18
      spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java
  44. 8
      spring-aop/src/test/java/org/springframework/aop/support/MethodMatchersTests.java
  45. 10
      spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java
  46. 2
      spring-aop/src/test/java/org/springframework/aop/support/PointcutsTests.java
  47. 14
      spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java
  48. 2
      spring-aop/src/test/java/org/springframework/aop/support/RootClassFilterTests.java
  49. 4
      spring-aop/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceProxyTests.java
  50. 12
      spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java
  51. 4
      spring-aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java
  52. 6
      spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java
  53. 4
      spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java
  54. 6
      spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java
  55. 4
      spring-aop/src/test/java/org/springframework/aop/target/dynamic/RefreshableTargetSourceTests.java
  56. 2
      spring-aop/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerEventTests-context.xml
  57. 2
      spring-aop/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests-pointcutDuplication.xml
  58. 2
      spring-aop/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests-pointcutMissing.xml
  59. 4
      spring-aop/src/test/resources/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests-context.xml
  60. 12
      spring-aop/src/test/resources/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests-context.xml
  61. 2
      spring-aop/src/test/resources/org/springframework/aop/target/CommonsPool2TargetSourceProxyTests-context.xml
  62. 4
      spring-aop/src/test/resources/org/springframework/aop/target/HotSwappableTargetSourceTests-context.xml
  63. 2
      spring-aop/src/test/resources/org/springframework/aop/target/LazyInitTargetSourceTests-customTarget.xml
  64. 2
      spring-aop/src/test/resources/org/springframework/aop/target/LazyInitTargetSourceTests-singleton.xml
  65. 6
      spring-aop/src/test/resources/org/springframework/aop/target/PrototypeTargetSourceTests-context.xml
  66. 8
      spring-aop/src/test/resources/org/springframework/aop/target/ThreadLocalTargetSourceTests-context.xml
  67. 4
      spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/advice/CountingAfterReturningAdvice.java
  68. 4
      spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/advice/CountingBeforeAdvice.java
  69. 4
      spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/advice/MethodCounter.java
  70. 5
      spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/advice/MyThrowsHandler.java
  71. 4
      spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/advice/TimestampIntroductionAdvisor.java
  72. 2
      spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/interceptor/NopInterceptor.java
  73. 2
      spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/interceptor/SerializableNopInterceptor.java
  74. 4
      spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/interceptor/TimestampIntroductionInterceptor.java
  75. 4
      spring-aspects/spring-aspects.gradle
  76. 882
      spring-aspects/src/test/java/org/springframework/cache/aspectj/AbstractCacheAnnotationTests.java
  77. 1
      spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJCacheAnnotationTests.java
  78. 12
      spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJEnableCachingIsolatedTests.java
  79. 9
      spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJEnableCachingTests.java
  80. 2
      spring-aspects/src/test/java/org/springframework/cache/aspectj/JCacheAspectJJavaConfigTests.java
  81. 2
      spring-aspects/src/test/java/org/springframework/cache/aspectj/JCacheAspectJNamespaceConfigTests.java
  82. 4
      spring-aspects/src/test/java/org/springframework/cache/config/AnnotatedClassCacheableService.java
  83. 6
      spring-aspects/src/test/java/org/springframework/cache/config/AnnotatedJCacheableService.java
  84. 6
      spring-aspects/src/test/java/org/springframework/cache/config/CacheableService.java
  85. 6
      spring-aspects/src/test/java/org/springframework/cache/config/DefaultCacheableService.java
  86. 22
      spring-aspects/src/test/java/org/springframework/cache/config/SomeKeyGenerator.java
  87. 9
      spring-aspects/src/test/java/org/springframework/cache/config/TestEntity.java
  88. 4
      spring-aspects/src/test/java/org/springframework/scheduling/aspectj/AnnotationAsyncExecutionAspectTests.java
  89. 2
      spring-aspects/src/test/java/org/springframework/transaction/aspectj/JtaTransactionAspectsTests.java
  90. 2
      spring-aspects/src/test/java/org/springframework/transaction/aspectj/TransactionAspectTests.java
  91. 4
      spring-aspects/src/test/resources/org/springframework/cache/config/annotation-cache-aspectj.xml
  92. 3
      spring-beans/spring-beans.gradle
  93. 16
      spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java
  94. 6
      spring-beans/src/test/java/org/springframework/beans/BeanUtilsTests.java
  95. 4
      spring-beans/src/test/java/org/springframework/beans/BeanWrapperEnumTests.java
  96. 8
      spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java
  97. 2
      spring-beans/src/test/java/org/springframework/beans/BeanWrapperTests.java
  98. 4
      spring-beans/src/test/java/org/springframework/beans/CachedIntrospectionResultsTests.java
  99. 2
      spring-beans/src/test/java/org/springframework/beans/DirectFieldAccessorTests.java
  100. 2
      spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java
  101. Some files were not shown because too many files have changed in this diff Show More

1
build.gradle

@ -308,6 +308,7 @@ configure([rootProject] + javaProjects) { project -> @@ -308,6 +308,7 @@ configure([rootProject] + javaProjects) { project ->
group = "org.springframework"
apply plugin: "java"
apply plugin: "java-test-fixtures"
apply plugin: "checkstyle"
apply plugin: 'org.springframework.build.compile'
apply from: "${rootDir}/gradle/ide.gradle"

16
buildSrc/README.md

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
# Spring Framework build
# Spring Framework Build
This folder contains the custom plugins and conventions for the Spring Framework build.
They are declared in the `build.gradle` file in this folder.
@ -7,8 +7,8 @@ They are declared in the `build.gradle` file in this folder. @@ -7,8 +7,8 @@ They are declared in the `build.gradle` file in this folder.
### Compiler conventions
The `org.springframework.build.compile` applies the Java compiler conventions to the build.
By default, the build is compiling sources with the `1.8` source and target compatibility.
The `org.springframework.build.compile` plubin applies the Java compiler conventions to the build.
By default, the build compiles sources with Java `1.8` source and target compatibility.
You can test a different source compatibility version on the CLI with a project property like:
```
@ -25,17 +25,11 @@ but doesn't affect the classpath of dependent projects. @@ -25,17 +25,11 @@ but doesn't affect the classpath of dependent projects.
This plugin does not provide a `provided` configuration, as the native `compileOnly` and `testCompileOnly`
configurations are preferred.
## Test sources
The `org.springframework.build.test-sources` updates `testCompile` dependencies to include
the test source sets of `project()` dependencies. This plugin is used in the Spring Framework build
to share test utilities and fixtures amongst modules.
## API Diff
This plugin uses the [Gradle JApiCmp](https://github.com/melix/japicmp-gradle-plugin) plugin
to generate API Diff reports for each Spring Framework module. This plugin is applied once on the root
project and create tasks in each framework module. Unlike previous versions of this part of the build,
project and creates tasks in each framework module. Unlike previous versions of this part of the build,
there is no need for checking out a specific tag. The plugin will fetch the JARs we want to compare the
current working version with. You can generate the reports for all modules or a single module:
@ -44,4 +38,4 @@ current working version with. You can generate the reports for all modules or a @@ -44,4 +38,4 @@ current working version with. You can generate the reports for all modules or a
./gradlew :spring-core:apiDiff -PbaselineVersion=5.1.0.RELEASE
```
The reports are located under `build/reports/api-diff/$OLDVERSION_to_$NEWVERSION/`.
The reports are located under `build/reports/api-diff/$OLDVERSION_to_$NEWVERSION/`.

4
buildSrc/build.gradle

@ -26,9 +26,5 @@ gradlePlugin { @@ -26,9 +26,5 @@ gradlePlugin {
id = "org.springframework.build.optional-dependencies"
implementationClass = "org.springframework.build.optional.OptionalDependenciesPlugin"
}
testSourcesPlugin {
id = "org.springframework.build.test-sources"
implementationClass = "org.springframework.build.testsources.TestSourcesPlugin"
}
}
}

95
buildSrc/src/main/java/org/springframework/build/testsources/TestSourcesPlugin.java

@ -1,95 +0,0 @@ @@ -1,95 +0,0 @@
/*
* Copyright 2002-2019 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.build.testsources;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.ProjectDependency;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetOutput;
import org.springframework.build.optional.OptionalDependenciesPlugin;
/**
* {@link Plugin} that automatically updates testCompile dependencies to include
* the test source sets of {@code project()} dependencies.
*
* <p>This plugin is used in the Spring Framework build to share test utilities and fixtures
* between projects.
*
* @author Phillip Webb
* @author Brian Clozel
*/
public class TestSourcesPlugin implements Plugin<Project> {
/**
* List of configurations this plugin should look for project dependencies in.
*/
@SuppressWarnings("deprecation")
private static final List<String> CONFIGURATIONS = Arrays.asList(
JavaPlugin.COMPILE_CONFIGURATION_NAME,
JavaPlugin.API_CONFIGURATION_NAME,
JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME,
OptionalDependenciesPlugin.OPTIONAL_CONFIGURATION_NAME,
JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME);
@Override
public void apply(Project project) {
project.getPlugins().withType(JavaPlugin.class, (plugin) -> addTestSourcesToProject(project));
}
private void addTestSourcesToProject(Project project) {
project.afterEvaluate(currentProject -> {
Set<ProjectDependency> projectDependencies = new LinkedHashSet<>();
collectProjectDependencies(projectDependencies, project);
projectDependencies.forEach(dep -> addTestSourcesFromDependency(currentProject, dep));
});
}
private void collectProjectDependencies(Set<ProjectDependency> projectDependencies, Project project) {
for (String configurationName : CONFIGURATIONS) {
Configuration configuration = project.getConfigurations().findByName(configurationName);
if (configuration != null) {
configuration.getDependencies().forEach(dependency -> {
if (dependency instanceof ProjectDependency) {
ProjectDependency projectDependency = (ProjectDependency) dependency;
projectDependencies.add(projectDependency);
collectProjectDependencies(projectDependencies, projectDependency.getDependencyProject());
}
});
}
}
}
private void addTestSourcesFromDependency(final Project currentProject, ProjectDependency dependency) {
Project dependencyProject = dependency.getDependencyProject();
dependencyProject.getPlugins().withType(JavaPlugin.class, plugin -> {
final JavaPluginConvention javaPlugin = dependencyProject.getConvention()
.getPlugin(JavaPluginConvention.class);
SourceSetOutput test = javaPlugin.getSourceSets().findByName(SourceSet.TEST_SOURCE_SET_NAME).getOutput();
currentProject.getDependencies().add(JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME, test);
});
}
}

9
gradle/spring-module.gradle

@ -1,6 +1,5 @@ @@ -1,6 +1,5 @@
apply plugin: 'org.springframework.build.compile'
apply plugin: 'org.springframework.build.optional-dependencies'
apply plugin: 'org.springframework.build.test-sources'
apply from: "$rootDir/gradle/publications.gradle"
jar {
@ -56,6 +55,14 @@ task javadocJar(type: Jar) { @@ -56,6 +55,14 @@ task javadocJar(type: Jar) {
publishing {
publications {
mavenJava(MavenPublication) {
// Disable publication of test fixture artifacts.
//
// Once we upgrade to Gradle 6.x, we will need to delete the following line ...
components.java.variants.removeAll { it.outgoingConfiguration.name.startsWith("testFixtures") }
// ... and uncomment the following two lines.
// components.java.withVariantsFromConfiguration(configurations.testFixturesApiElements) { skip() }
// components.java.withVariantsFromConfiguration(configurations.testFixturesRuntimeElements) { skip() }
from components.java
artifact sourcesJar
artifact javadocJar

6
integration-tests/integration-tests.gradle

@ -1,12 +1,14 @@ @@ -1,12 +1,14 @@
description = "Spring Integration Tests"
apply plugin: "org.springframework.build.test-sources"
dependencies {
testCompile(project(":spring-aop"))
testCompile(project(":spring-beans"))
testCompile(project(":spring-context"))
testCompile(project(":spring-core"))
testCompile(testFixtures(project(":spring-aop")))
testCompile(testFixtures(project(":spring-beans")))
testCompile(testFixtures(project(":spring-core")))
testCompile(testFixtures(project(":spring-tx")))
testCompile(project(":spring-expression"))
testCompile(project(":spring-jdbc"))
testCompile(project(":spring-orm"))

6
integration-tests/src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests.java

@ -21,12 +21,12 @@ import org.junit.jupiter.api.Test; @@ -21,12 +21,12 @@ import org.junit.jupiter.api.Test;
import org.springframework.aop.framework.Advised;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.core.testfixture.io.SerializationTestUtils;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpSession;
import org.springframework.test.context.junit.jupiter.web.SpringJUnitWebConfig;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.util.SerializationTestUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

10
integration-tests/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java

@ -26,17 +26,17 @@ import org.junit.jupiter.api.Test; @@ -26,17 +26,17 @@ import org.junit.jupiter.api.Test;
import org.springframework.aop.support.AopUtils;
import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor;
import org.springframework.aop.testfixture.advice.CountingBeforeAdvice;
import org.springframework.aop.testfixture.advice.MethodCounter;
import org.springframework.aop.testfixture.interceptor.NopInterceptor;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.lang.Nullable;
import org.springframework.tests.aop.advice.CountingBeforeAdvice;
import org.springframework.tests.aop.advice.MethodCounter;
import org.springframework.tests.aop.interceptor.NopInterceptor;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.transaction.CallCountingTransactionManager;
import org.springframework.transaction.NoTransactionException;
import org.springframework.transaction.interceptor.TransactionInterceptor;
import org.springframework.transaction.testfixture.CallCountingTransactionManager;
import static org.assertj.core.api.Assertions.assertThat;

6
integration-tests/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java

@ -28,19 +28,19 @@ import org.springframework.beans.factory.annotation.Autowired; @@ -28,19 +28,19 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.testfixture.EnabledForTestGroups;
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
import org.springframework.dao.support.PersistenceExceptionTranslator;
import org.springframework.stereotype.Repository;
import org.springframework.tests.EnabledForTestGroups;
import org.springframework.tests.transaction.CallCountingTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.testfixture.CallCountingTransactionManager;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.Mockito.mock;
import static org.springframework.tests.TestGroup.PERFORMANCE;
import static org.springframework.core.testfixture.TestGroup.PERFORMANCE;
/**
* Integration tests cornering bug SPR-8651, which revealed that @Scheduled methods may

2
integration-tests/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementIntegrationTests.java

@ -40,9 +40,9 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager; @@ -40,9 +40,9 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
import org.springframework.stereotype.Repository;
import org.springframework.tests.transaction.CallCountingTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor;
import org.springframework.transaction.testfixture.CallCountingTransactionManager;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

8
integration-tests/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests-context.xml

@ -11,19 +11,19 @@ @@ -11,19 +11,19 @@
<bean id="advice" class="org.springframework.aop.interceptor.DebugInterceptor"/>
<bean id="testBean" class="org.springframework.tests.sample.beans.TestBean"/>
<bean id="testBean" class="org.springframework.beans.testfixture.beans.TestBean"/>
<bean id="singletonScoped" class="org.springframework.tests.sample.beans.TestBean">
<bean id="singletonScoped" class="org.springframework.beans.testfixture.beans.TestBean">
<aop:scoped-proxy/>
<property name="name" value="Rob Harrop"/>
</bean>
<bean id="requestScoped" class="org.springframework.tests.sample.beans.TestBean" scope="request">
<bean id="requestScoped" class="org.springframework.beans.testfixture.beans.TestBean" scope="request">
<aop:scoped-proxy/>
<property name="name" value="Rob Harrop"/>
</bean>
<bean id="sessionScoped" name="sessionScopedAlias" class="org.springframework.tests.sample.beans.TestBean" scope="session">
<bean id="sessionScoped" name="sessionScopedAlias" class="org.springframework.beans.testfixture.beans.TestBean" scope="session">
<aop:scoped-proxy proxy-target-class="false"/>
<property name="name" value="Rob Harrop"/>
</bean>

14
integration-tests/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests-context.xml

@ -34,7 +34,7 @@ @@ -34,7 +34,7 @@
</bean>
<!-- Often we can leave the definition of such infrastructural beans to child factories -->
<bean id="txManager" class="org.springframework.tests.transaction.CallCountingTransactionManager"/>
<bean id="txManager" class="org.springframework.transaction.testfixture.CallCountingTransactionManager"/>
<bean id="tas" class="org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource">
<property name="properties">
@ -74,20 +74,20 @@ @@ -74,20 +74,20 @@
<!-- These two beans would otherwise be eligible for autoproxying -->
<bean id="singletonDependency" class="org.springframework.tests.sample.beans.TestBean" scope="singleton"/>
<bean id="singletonDependency" class="org.springframework.beans.testfixture.beans.TestBean" scope="singleton"/>
<bean id="prototypeDependency" class="org.springframework.tests.sample.beans.TestBean" scope="prototype"/>
<bean id="prototypeDependency" class="org.springframework.beans.testfixture.beans.TestBean" scope="prototype"/>
<!-- ====== End test for prototype definitions to try to provoke circular references ========================= -->
<bean class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
<property name="advice"><ref bean="countingAdvice"/></property>
<property name="pattern"><value>org.springframework.tests.sample.beans.ITestBean.getName</value></property>
<property name="pattern"><value>org.springframework.beans.testfixture.beans.ITestBean.getName</value></property>
</bean>
<bean id="countingAdvice" class="org.springframework.tests.aop.advice.CountingAfterReturningAdvice"/>
<bean id="countingAdvice" class="org.springframework.aop.testfixture.advice.CountingAfterReturningAdvice"/>
<bean id="test" class="org.springframework.tests.sample.beans.TestBean">
<bean id="test" class="org.springframework.beans.testfixture.beans.TestBean">
<property name="age"><value>4</value></property>
</bean>
@ -97,7 +97,7 @@ @@ -97,7 +97,7 @@
<!-- The following beans test whether auto-proxying falls over for a null value -->
<bean id="tb" class="org.springframework.tests.sample.beans.TestBean"/>
<bean id="tb" class="org.springframework.beans.testfixture.beans.TestBean"/>
<bean id="nullValueReturned" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject" ref="tb"/>

3
spring-aop/spring-aop.gradle

@ -6,4 +6,7 @@ dependencies { @@ -6,4 +6,7 @@ dependencies {
optional("org.aspectj:aspectjweaver")
optional("org.apache.commons:commons-pool2")
optional("com.jamonapi:jamon")
testCompile(testFixtures(project(":spring-beans")))
testCompile(testFixtures(project(":spring-core")))
testFixturesImplementation(testFixtures(project(":spring-core")))
}

26
spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutTests.java

@ -31,10 +31,10 @@ import org.springframework.aop.MethodMatcher; @@ -31,10 +31,10 @@ import org.springframework.aop.MethodMatcher;
import org.springframework.aop.Pointcut;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.tests.sample.beans.IOther;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.tests.sample.beans.subpkg.DeepBean;
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 static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
@ -67,7 +67,7 @@ public class AspectJExpressionPointcutTests { @@ -67,7 +67,7 @@ public class AspectJExpressionPointcutTests {
@Test
public void testMatchExplicit() {
String expression = "execution(int org.springframework.tests.sample.beans.TestBean.getAge())";
String expression = "execution(int org.springframework.beans.testfixture.beans.TestBean.getAge())";
Pointcut pointcut = getPointcut(expression);
ClassFilter classFilter = pointcut.getClassFilter();
@ -117,8 +117,8 @@ public class AspectJExpressionPointcutTests { @@ -117,8 +117,8 @@ public class AspectJExpressionPointcutTests {
* @param which this or target
*/
private void testThisOrTarget(String which) throws SecurityException, NoSuchMethodException {
String matchesTestBean = which + "(org.springframework.tests.sample.beans.TestBean)";
String matchesIOther = which + "(org.springframework.tests.sample.beans.IOther)";
String matchesTestBean = which + "(org.springframework.beans.testfixture.beans.TestBean)";
String matchesIOther = which + "(org.springframework.beans.testfixture.beans.IOther)";
AspectJExpressionPointcut testBeanPc = new AspectJExpressionPointcut();
testBeanPc.setExpression(matchesTestBean);
@ -142,7 +142,7 @@ public class AspectJExpressionPointcutTests { @@ -142,7 +142,7 @@ public class AspectJExpressionPointcutTests {
}
private void testWithinPackage(boolean matchSubpackages) throws SecurityException, NoSuchMethodException {
String withinBeansPackage = "within(org.springframework.tests.sample.beans.";
String withinBeansPackage = "within(org.springframework.beans.testfixture.beans.";
// Subpackages are matched by **
if (matchSubpackages) {
withinBeansPackage += ".";
@ -187,7 +187,7 @@ public class AspectJExpressionPointcutTests { @@ -187,7 +187,7 @@ public class AspectJExpressionPointcutTests {
@Test
public void testMatchWithArgs() throws Exception {
String expression = "execution(void org.springframework.tests.sample.beans.TestBean.setSomeNumber(Number)) && args(Double)";
String expression = "execution(void org.springframework.beans.testfixture.beans.TestBean.setSomeNumber(Number)) && args(Double)";
Pointcut pointcut = getPointcut(expression);
ClassFilter classFilter = pointcut.getClassFilter();
@ -206,7 +206,7 @@ public class AspectJExpressionPointcutTests { @@ -206,7 +206,7 @@ public class AspectJExpressionPointcutTests {
@Test
public void testSimpleAdvice() {
String expression = "execution(int org.springframework.tests.sample.beans.TestBean.getAge())";
String expression = "execution(int org.springframework.beans.testfixture.beans.TestBean.getAge())";
CallCountingInterceptor interceptor = new CallCountingInterceptor();
TestBean testBean = getAdvisedProxy(expression, interceptor);
@ -219,7 +219,7 @@ public class AspectJExpressionPointcutTests { @@ -219,7 +219,7 @@ public class AspectJExpressionPointcutTests {
@Test
public void testDynamicMatchingProxy() {
String expression = "execution(void org.springframework.tests.sample.beans.TestBean.setSomeNumber(Number)) && args(Double)";
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 +233,7 @@ public class AspectJExpressionPointcutTests { @@ -233,7 +233,7 @@ public class AspectJExpressionPointcutTests {
@Test
public void testInvalidExpression() {
String expression = "execution(void org.springframework.tests.sample.beans.TestBean.setSomeNumber(Number) && args(Double)";
String expression = "execution(void org.springframework.beans.testfixture.beans.TestBean.setSomeNumber(Number) && args(Double)";
assertThatIllegalArgumentException().isThrownBy(
getPointcut(expression)::getClassFilter); // call to getClassFilter forces resolution
}
@ -264,7 +264,7 @@ public class AspectJExpressionPointcutTests { @@ -264,7 +264,7 @@ public class AspectJExpressionPointcutTests {
@Test
public void testWithUnsupportedPointcutPrimitive() {
String expression = "call(int org.springframework.tests.sample.beans.TestBean.getAge())";
String expression = "call(int org.springframework.beans.testfixture.beans.TestBean.getAge())";
assertThatExceptionOfType(UnsupportedPointcutPrimitiveException.class).isThrownBy(() ->
getPointcut(expression).getClassFilter()) // call to getClassFilter forces resolution...
.satisfies(ex -> assertThat(ex.getUnsupportedPrimitive()).isEqualTo(PointcutPrimitive.CALL));

2
spring-aop/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutMatchingTests.java

@ -18,7 +18,7 @@ package org.springframework.aop.aspectj; @@ -18,7 +18,7 @@ package org.springframework.aop.aspectj;
import org.junit.jupiter.api.Test;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.testfixture.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;

4
spring-aop/src/test/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPointTests.java

@ -33,8 +33,8 @@ import org.springframework.aop.framework.AopContext; @@ -33,8 +33,8 @@ import org.springframework.aop.framework.AopContext;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.interceptor.ExposeInvocationInterceptor;
import org.springframework.aop.support.AopUtils;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.beans.testfixture.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

4
spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJExpressionPointcutTests.java

@ -27,7 +27,7 @@ import test.annotation.EmptySpringAnnotation; @@ -27,7 +27,7 @@ import test.annotation.EmptySpringAnnotation;
import test.annotation.transaction.Tx;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.testfixture.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
@ -56,7 +56,7 @@ public class TigerAspectJExpressionPointcutTests { @@ -56,7 +56,7 @@ public class TigerAspectJExpressionPointcutTests {
@Test
public void testMatchGenericArgument() {
String expression = "execution(* set*(java.util.List<org.springframework.tests.sample.beans.TestBean>) )";
String expression = "execution(* set*(java.util.List<org.springframework.beans.testfixture.beans.TestBean>) )";
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
ajexp.setExpression(expression);

28
spring-aop/src/test/java/org/springframework/aop/aspectj/TypePatternClassFilterTests.java

@ -20,11 +20,11 @@ import org.junit.jupiter.api.Test; @@ -20,11 +20,11 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.tests.sample.beans.CountingTestBean;
import org.springframework.tests.sample.beans.IOther;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.tests.sample.beans.subpkg.DeepBean;
import org.springframework.beans.testfixture.beans.CountingTestBean;
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 static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
@ -57,7 +57,7 @@ class TypePatternClassFilterTests { @@ -57,7 +57,7 @@ class TypePatternClassFilterTests {
@Test
void validPatternMatching() {
TypePatternClassFilter tpcf = new TypePatternClassFilter("org.springframework.tests.sample.beans.*");
TypePatternClassFilter tpcf = new TypePatternClassFilter("org.springframework.beans.testfixture.beans.*");
assertThat(tpcf.matches(TestBean.class)).as("Must match: in package").isTrue();
assertThat(tpcf.matches(ITestBean.class)).as("Must match: in package").isTrue();
@ -70,7 +70,7 @@ class TypePatternClassFilterTests { @@ -70,7 +70,7 @@ class TypePatternClassFilterTests {
@Test
void subclassMatching() {
TypePatternClassFilter tpcf = new TypePatternClassFilter("org.springframework.tests.sample.beans.ITestBean+");
TypePatternClassFilter tpcf = new TypePatternClassFilter("org.springframework.beans.testfixture.beans.ITestBean+");
assertThat(tpcf.matches(TestBean.class)).as("Must match: in package").isTrue();
assertThat(tpcf.matches(ITestBean.class)).as("Must match: in package").isTrue();
@ -98,8 +98,8 @@ class TypePatternClassFilterTests { @@ -98,8 +98,8 @@ class TypePatternClassFilterTests {
@Test
void testEquals() {
TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.tests.sample.beans.*");
TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.tests.sample.beans.*");
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.*");
assertThat(filter1).isEqualTo(filter2);
@ -108,8 +108,8 @@ class TypePatternClassFilterTests { @@ -108,8 +108,8 @@ class TypePatternClassFilterTests {
@Test
void testHashCode() {
TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.tests.sample.beans.*");
TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.tests.sample.beans.*");
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.*");
assertThat(filter1.hashCode()).isEqualTo(filter2.hashCode());
@ -118,11 +118,11 @@ class TypePatternClassFilterTests { @@ -118,11 +118,11 @@ class TypePatternClassFilterTests {
@Test
void testToString() {
TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.tests.sample.beans.*");
TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.tests.sample.beans.*");
TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.beans.testfixture.beans.*");
TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.beans.testfixture.beans.*");
assertThat(filter1.toString())
.isEqualTo("org.springframework.aop.aspectj.TypePatternClassFilter: org.springframework.tests.sample.beans.*");
.isEqualTo("org.springframework.aop.aspectj.TypePatternClassFilter: org.springframework.beans.testfixture.beans.*");
assertThat(filter1.toString()).isEqualTo(filter2.toString());
}

8
spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java

@ -50,11 +50,11 @@ import org.springframework.aop.framework.AopConfigException; @@ -50,11 +50,11 @@ import org.springframework.aop.framework.AopConfigException;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.interceptor.ExposeInvocationInterceptor;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.core.OrderComparator;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.util.ObjectUtils;
import static org.assertj.core.api.Assertions.assertThat;
@ -590,7 +590,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests { @@ -590,7 +590,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
}
@Aspect("pertypewithin(org.springframework.tests.sample.beans.IOther+)")
@Aspect("pertypewithin(org.springframework.beans.testfixture.beans.IOther+)")
public static class PerTypeWithinAspect {
public int count;
@ -931,7 +931,7 @@ abstract class AbstractMakeModifiable { @@ -931,7 +931,7 @@ abstract class AbstractMakeModifiable {
@Aspect
class MakeITestBeanModifiable extends AbstractMakeModifiable {
@DeclareParents(value = "org.springframework.tests.sample.beans.ITestBean+",
@DeclareParents(value = "org.springframework.beans.testfixture.beans.ITestBean+",
defaultImpl=ModifiableImpl.class)
public static MutableModifiable mixin;

4
spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/ArgumentBindingTests.java

@ -27,8 +27,8 @@ import org.aspectj.lang.annotation.Pointcut; @@ -27,8 +27,8 @@ import org.aspectj.lang.annotation.Pointcut;
import org.junit.jupiter.api.Test;
import org.springframework.aop.aspectj.AspectJAdviceParameterNameDiscoverer;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.beans.testfixture.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;

2
spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJPointcutAdvisorTests.java

@ -23,7 +23,7 @@ import org.springframework.aop.Pointcut; @@ -23,7 +23,7 @@ import org.springframework.aop.Pointcut;
import org.springframework.aop.aspectj.AspectJExpressionPointcut;
import org.springframework.aop.aspectj.AspectJExpressionPointcutTests;
import org.springframework.aop.framework.AopConfigException;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.testfixture.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

2
spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java

@ -26,7 +26,7 @@ import org.aspectj.lang.annotation.Aspect; @@ -26,7 +26,7 @@ import org.aspectj.lang.annotation.Aspect;
import org.junit.jupiter.api.Test;
import test.aop.PerThisAspect;
import org.springframework.util.SerializationTestUtils;
import org.springframework.core.testfixture.io.SerializationTestUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;

2
spring-aop/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJNamespaceHandlerTests.java

@ -29,7 +29,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; @@ -29,7 +29,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.beans.factory.xml.XmlReaderContext;
import org.springframework.tests.beans.CollectingReaderEventListener;
import org.springframework.beans.testfixture.beans.CollectingReaderEventListener;
import static org.assertj.core.api.Assertions.assertThat;

4
spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java

@ -29,11 +29,11 @@ import org.springframework.beans.factory.parsing.ComponentDefinition; @@ -29,11 +29,11 @@ import org.springframework.beans.factory.parsing.ComponentDefinition;
import org.springframework.beans.factory.parsing.CompositeComponentDefinition;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.beans.testfixture.beans.CollectingReaderEventListener;
import org.springframework.core.io.Resource;
import org.springframework.tests.beans.CollectingReaderEventListener;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.tests.TestResourceUtils.qualifiedResource;
import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource;
/**
* @author Rob Harrop

2
spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java

@ -24,7 +24,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; @@ -24,7 +24,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.springframework.tests.TestResourceUtils.qualifiedResource;
import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource;
/**
* @author Mark Fisher

2
spring-aop/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java

@ -22,7 +22,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; @@ -22,7 +22,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.tests.TestResourceUtils.qualifiedResource;
import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource;
/**
* Tests that the &lt;aop:config/&gt; element can be used as a top level element.

4
spring-aop/src/test/java/org/springframework/aop/framework/AopProxyUtilsTests.java

@ -23,8 +23,8 @@ import java.util.List; @@ -23,8 +23,8 @@ import java.util.List;
import org.junit.jupiter.api.Test;
import org.springframework.aop.SpringProxy;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.beans.testfixture.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;

4
spring-aop/src/test/java/org/springframework/aop/framework/IntroductionBenchmarkTests.java

@ -19,8 +19,8 @@ package org.springframework.aop.framework; @@ -19,8 +19,8 @@ package org.springframework.aop.framework;
import org.junit.jupiter.api.Test;
import org.springframework.aop.support.DelegatingIntroductionInterceptor;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.util.StopWatch;
/**

2
spring-aop/src/test/java/org/springframework/aop/framework/MethodInvocationTests.java

@ -23,7 +23,7 @@ import java.util.List; @@ -23,7 +23,7 @@ import java.util.List;
import org.aopalliance.intercept.MethodInterceptor;
import org.junit.jupiter.api.Test;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.testfixture.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;

2
spring-aop/src/test/java/org/springframework/aop/framework/PrototypeTargetTests.java

@ -25,7 +25,7 @@ import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; @@ -25,7 +25,7 @@ import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.Resource;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.tests.TestResourceUtils.qualifiedResource;
import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource;
/**
* @author Juergen Hoeller

38
spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java

@ -33,15 +33,15 @@ import org.springframework.aop.interceptor.DebugInterceptor; @@ -33,15 +33,15 @@ import org.springframework.aop.interceptor.DebugInterceptor;
import org.springframework.aop.support.AopUtils;
import org.springframework.aop.support.DefaultIntroductionAdvisor;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.aop.support.DelegatingIntroductionInterceptor;
import org.springframework.aop.testfixture.advice.CountingBeforeAdvice;
import org.springframework.aop.testfixture.interceptor.NopInterceptor;
import org.springframework.aop.testfixture.interceptor.TimestampIntroductionInterceptor;
import org.springframework.beans.testfixture.beans.IOther;
import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
import org.springframework.core.annotation.Order;
import org.springframework.tests.TimeStamped;
import org.springframework.tests.aop.advice.CountingBeforeAdvice;
import org.springframework.tests.aop.interceptor.NopInterceptor;
import org.springframework.tests.sample.beans.IOther;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.core.testfixture.TimeStamped;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
@ -371,30 +371,6 @@ public class ProxyFactoryTests { @@ -371,30 +371,6 @@ public class ProxyFactoryTests {
}
@SuppressWarnings("serial")
private static class TimestampIntroductionInterceptor extends DelegatingIntroductionInterceptor
implements TimeStamped {
private long ts;
public TimestampIntroductionInterceptor() {
}
public TimestampIntroductionInterceptor(long ts) {
this.ts = ts;
}
public void setTime(long ts) {
this.ts = ts;
}
@Override
public long getTimeStamp() {
return ts;
}
}
@Order(2)
public static class A implements Runnable {

24
spring-aop/src/test/java/org/springframework/aop/framework/adapter/ThrowsAdviceInterceptorTests.java

@ -17,16 +17,13 @@ @@ -17,16 +17,13 @@
package org.springframework.aop.framework.adapter;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.reflect.Method;
import java.rmi.ConnectException;
import java.rmi.RemoteException;
import org.aopalliance.intercept.MethodInvocation;
import org.junit.jupiter.api.Test;
import org.springframework.aop.ThrowsAdvice;
import org.springframework.tests.aop.advice.MethodCounter;
import org.springframework.aop.testfixture.advice.MyThrowsHandler;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
@ -128,23 +125,4 @@ public class ThrowsAdviceInterceptorTests { @@ -128,23 +125,4 @@ public class ThrowsAdviceInterceptorTests {
assertThat(th.getCalls("remoteException")).isEqualTo(1);
}
@SuppressWarnings("serial")
static class MyThrowsHandler extends MethodCounter implements ThrowsAdvice {
// Full method signature
public void afterThrowing(Method m, Object[] args, Object target, IOException ex) {
count("ioException");
}
public void afterThrowing(RemoteException ex) throws Throwable {
count("remoteException");
}
/** Not valid, wrong number of arguments */
public void afterThrowing(Method m, Exception ex) throws Throwable {
throw new UnsupportedOperationException("Shouldn't be called");
}
}
}

8
spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java

@ -22,10 +22,10 @@ import org.junit.jupiter.api.Test; @@ -22,10 +22,10 @@ import org.junit.jupiter.api.Test;
import org.springframework.aop.framework.Advised;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.tests.sample.beans.DerivedTestBean;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.util.SerializationTestUtils;
import org.springframework.beans.testfixture.beans.DerivedTestBean;
import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.core.testfixture.io.SerializationTestUtils;
import static org.assertj.core.api.Assertions.assertThat;

4
spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeBeanNameAdvisorsTests.java

@ -20,8 +20,8 @@ import org.junit.jupiter.api.Test; @@ -20,8 +20,8 @@ import org.junit.jupiter.api.Test;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.factory.NamedBean;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.beans.testfixture.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;

6
spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java

@ -21,11 +21,11 @@ import org.junit.jupiter.api.Test; @@ -21,11 +21,11 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.beans.testfixture.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.tests.TestResourceUtils.qualifiedResource;
import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource;
/**
* Non-XML tests are in AbstractAopProxyTests

2
spring-aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java

@ -24,7 +24,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; @@ -24,7 +24,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.tests.TestResourceUtils.qualifiedResource;
import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource;
/**
* @author Mark Fisher

4
spring-aop/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java

@ -21,8 +21,8 @@ import java.io.IOException; @@ -21,8 +21,8 @@ import java.io.IOException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.util.SerializationTestUtils;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.core.testfixture.io.SerializationTestUtils;
import static org.assertj.core.api.Assertions.assertThat;

6
spring-aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java

@ -25,10 +25,10 @@ import org.springframework.aop.MethodMatcher; @@ -25,10 +25,10 @@ import org.springframework.aop.MethodMatcher;
import org.springframework.aop.Pointcut;
import org.springframework.aop.interceptor.ExposeInvocationInterceptor;
import org.springframework.aop.target.EmptyTargetSource;
import org.springframework.aop.testfixture.interceptor.NopInterceptor;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.core.testfixture.io.SerializationTestUtils;
import org.springframework.lang.Nullable;
import org.springframework.tests.aop.interceptor.NopInterceptor;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.util.SerializationTestUtils;
import static org.assertj.core.api.Assertions.assertThat;

4
spring-aop/src/test/java/org/springframework/aop/support/ClassFiltersTests.java

@ -19,9 +19,9 @@ package org.springframework.aop.support; @@ -19,9 +19,9 @@ package org.springframework.aop.support;
import org.junit.jupiter.api.Test;
import org.springframework.aop.ClassFilter;
import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.core.NestedRuntimeException;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;

2
spring-aop/src/test/java/org/springframework/aop/support/ClassUtilsTests.java

@ -18,7 +18,7 @@ package org.springframework.aop.support; @@ -18,7 +18,7 @@ package org.springframework.aop.support;
import org.junit.jupiter.api.Test;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.util.ClassUtils;
import static org.assertj.core.api.Assertions.assertThat;

2
spring-aop/src/test/java/org/springframework/aop/support/ComposablePointcutTests.java

@ -23,9 +23,9 @@ import org.junit.jupiter.api.Test; @@ -23,9 +23,9 @@ import org.junit.jupiter.api.Test;
import org.springframework.aop.ClassFilter;
import org.springframework.aop.MethodMatcher;
import org.springframework.aop.Pointcut;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.core.NestedRuntimeException;
import org.springframework.lang.Nullable;
import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;

6
spring-aop/src/test/java/org/springframework/aop/support/ControlFlowPointcutTests.java

@ -20,9 +20,9 @@ import org.junit.jupiter.api.Test; @@ -20,9 +20,9 @@ import org.junit.jupiter.api.Test;
import org.springframework.aop.Pointcut;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.tests.aop.interceptor.NopInterceptor;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.aop.testfixture.interceptor.NopInterceptor;
import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.beans.testfixture.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;

18
spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java

@ -24,15 +24,15 @@ import org.junit.jupiter.api.Test; @@ -24,15 +24,15 @@ import org.junit.jupiter.api.Test;
import org.springframework.aop.IntroductionAdvisor;
import org.springframework.aop.IntroductionInterceptor;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.tests.TimeStamped;
import org.springframework.tests.aop.interceptor.SerializableNopInterceptor;
import org.springframework.tests.sample.beans.INestedTestBean;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.NestedTestBean;
import org.springframework.tests.sample.beans.Person;
import org.springframework.tests.sample.beans.SerializablePerson;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.util.SerializationTestUtils;
import org.springframework.aop.testfixture.interceptor.SerializableNopInterceptor;
import org.springframework.beans.testfixture.beans.INestedTestBean;
import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.beans.testfixture.beans.NestedTestBean;
import org.springframework.beans.testfixture.beans.Person;
import org.springframework.beans.testfixture.beans.SerializablePerson;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.core.testfixture.TimeStamped;
import org.springframework.core.testfixture.io.SerializationTestUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;

8
spring-aop/src/test/java/org/springframework/aop/support/MethodMatchersTests.java

@ -21,11 +21,11 @@ import java.lang.reflect.Method; @@ -21,11 +21,11 @@ import java.lang.reflect.Method;
import org.junit.jupiter.api.Test;
import org.springframework.aop.MethodMatcher;
import org.springframework.beans.testfixture.beans.IOther;
import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.core.testfixture.io.SerializationTestUtils;
import org.springframework.lang.Nullable;
import org.springframework.tests.sample.beans.IOther;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.util.SerializationTestUtils;
import static org.assertj.core.api.Assertions.assertThat;

10
spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java

@ -21,11 +21,11 @@ import org.junit.jupiter.api.Test; @@ -21,11 +21,11 @@ import org.junit.jupiter.api.Test;
import org.springframework.aop.framework.Advised;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.tests.aop.interceptor.NopInterceptor;
import org.springframework.tests.aop.interceptor.SerializableNopInterceptor;
import org.springframework.tests.sample.beans.Person;
import org.springframework.tests.sample.beans.SerializablePerson;
import org.springframework.util.SerializationTestUtils;
import org.springframework.aop.testfixture.interceptor.NopInterceptor;
import org.springframework.aop.testfixture.interceptor.SerializableNopInterceptor;
import org.springframework.beans.testfixture.beans.Person;
import org.springframework.beans.testfixture.beans.SerializablePerson;
import org.springframework.core.testfixture.io.SerializationTestUtils;
import static org.assertj.core.api.Assertions.assertThat;

2
spring-aop/src/test/java/org/springframework/aop/support/PointcutsTests.java

@ -22,8 +22,8 @@ import org.junit.jupiter.api.Test; @@ -22,8 +22,8 @@ import org.junit.jupiter.api.Test;
import org.springframework.aop.ClassFilter;
import org.springframework.aop.Pointcut;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.lang.Nullable;
import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;

14
spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java

@ -19,18 +19,18 @@ package org.springframework.aop.support; @@ -19,18 +19,18 @@ package org.springframework.aop.support;
import org.junit.jupiter.api.Test;
import org.springframework.aop.framework.Advised;
import org.springframework.aop.testfixture.interceptor.NopInterceptor;
import org.springframework.aop.testfixture.interceptor.SerializableNopInterceptor;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.beans.testfixture.beans.Person;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.core.io.Resource;
import org.springframework.tests.aop.interceptor.NopInterceptor;
import org.springframework.tests.aop.interceptor.SerializableNopInterceptor;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.Person;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.util.SerializationTestUtils;
import org.springframework.core.testfixture.io.SerializationTestUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.tests.TestResourceUtils.qualifiedResource;
import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource;
/**
* @author Rod Johnson

2
spring-aop/src/test/java/org/springframework/aop/support/RootClassFilterTests.java

@ -19,7 +19,7 @@ package org.springframework.aop.support; @@ -19,7 +19,7 @@ package org.springframework.aop.support;
import org.junit.jupiter.api.Test;
import org.springframework.aop.ClassFilter;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.beans.testfixture.beans.ITestBean;
import static org.assertj.core.api.Assertions.assertThat;

4
spring-aop/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceProxyTests.java

@ -21,11 +21,11 @@ import org.junit.jupiter.api.Test; @@ -21,11 +21,11 @@ import org.junit.jupiter.api.Test;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.core.io.Resource;
import org.springframework.tests.sample.beans.ITestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.tests.TestResourceUtils.qualifiedResource;
import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource;
/**
* @author Stephane Nicoll

12
spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java

@ -23,17 +23,17 @@ import org.junit.jupiter.api.Test; @@ -23,17 +23,17 @@ import org.junit.jupiter.api.Test;
import org.springframework.aop.framework.Advised;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.aop.testfixture.interceptor.SerializableNopInterceptor;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.tests.aop.interceptor.SerializableNopInterceptor;
import org.springframework.tests.sample.beans.Person;
import org.springframework.tests.sample.beans.SerializablePerson;
import org.springframework.tests.sample.beans.SideEffectBean;
import org.springframework.util.SerializationTestUtils;
import org.springframework.beans.testfixture.beans.Person;
import org.springframework.beans.testfixture.beans.SerializablePerson;
import org.springframework.beans.testfixture.beans.SideEffectBean;
import org.springframework.core.testfixture.io.SerializationTestUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.springframework.tests.TestResourceUtils.qualifiedResource;
import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource;
/**
* @author Rod Johnson

4
spring-aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java

@ -22,11 +22,11 @@ import org.junit.jupiter.api.Test; @@ -22,11 +22,11 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.core.io.Resource;
import org.springframework.tests.sample.beans.ITestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.tests.TestResourceUtils.qualifiedResource;
import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource;
/**
* @author Juergen Hoeller

6
spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java

@ -23,9 +23,9 @@ import org.springframework.beans.MutablePropertyValues; @@ -23,9 +23,9 @@ import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.tests.sample.beans.SerializablePerson;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.util.SerializationTestUtils;
import org.springframework.beans.testfixture.beans.SerializablePerson;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.core.testfixture.io.SerializationTestUtils;
import static org.assertj.core.api.Assertions.assertThat;

4
spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java

@ -21,10 +21,10 @@ import org.junit.jupiter.api.Test; @@ -21,10 +21,10 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.tests.sample.beans.SideEffectBean;
import org.springframework.beans.testfixture.beans.SideEffectBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.tests.TestResourceUtils.qualifiedResource;
import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource;
/**
* @author Rod Johnson

6
spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java

@ -21,11 +21,11 @@ import org.junit.jupiter.api.Test; @@ -21,11 +21,11 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.SideEffectBean;
import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.beans.testfixture.beans.SideEffectBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.tests.TestResourceUtils.qualifiedResource;
import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource;
/**
* @author Rod Johnson

4
spring-aop/src/test/java/org/springframework/aop/target/dynamic/RefreshableTargetSourceTests.java

@ -18,10 +18,10 @@ package org.springframework.aop.target.dynamic; @@ -18,10 +18,10 @@ package org.springframework.aop.target.dynamic;
import org.junit.jupiter.api.Test;
import org.springframework.tests.EnabledForTestGroups;
import org.springframework.core.testfixture.EnabledForTestGroups;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.tests.TestGroup.PERFORMANCE;
import static org.springframework.core.testfixture.TestGroup.PERFORMANCE;
/**
* @author Rob Harrop

2
spring-aop/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerEventTests-context.xml

@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
<bean id="getAgeCounter" class="org.springframework.aop.framework.CountingBeforeAdvice"/>
<bean id="testBean" class="org.springframework.tests.sample.beans.TestBean"/>
<bean id="testBean" class="org.springframework.beans.testfixture.beans.TestBean"/>
<bean id="countingAdvice" class="org.springframework.aop.config.CountingAspectJAdvice"/>

2
spring-aop/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests-pointcutDuplication.xml

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
<bean id="getAgeCounter" class="org.springframework.aop.framework.CountingBeforeAdvice"/>
<bean id="testBean" class="org.springframework.tests.sample.beans.TestBean"/>
<bean id="testBean" class="org.springframework.beans.testfixture.beans.TestBean"/>
<bean id="countingAdvice" class="org.springframework.aop.config.CountingAspectJAdvice"/>

2
spring-aop/src/test/resources/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests-pointcutMissing.xml

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
<bean id="getAgeCounter" class="org.springframework.aop.framework.CountingBeforeAdvice"/>
<bean id="testBean" class="org.springframework.tests.sample.beans.TestBean"/>
<bean id="testBean" class="org.springframework.beans.testfixture.beans.TestBean"/>
<bean id="countingAdvice" class="org.springframework.aop.config.CountingAspectJAdvice"/>

4
spring-aop/src/test/resources/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests-context.xml

@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
-->
<beans>
<bean id="nopInterceptor" class="org.springframework.tests.aop.interceptor.NopInterceptor"/>
<bean id="nopInterceptor" class="org.springframework.aop.testfixture.interceptor.NopInterceptor"/>
<bean id="exposeInvocation" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
<property name="targetClass">
@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
<property name="targetField"><value>INSTANCE</value></property>
</bean>
<bean id="countingBeforeAdvice" class="org.springframework.tests.aop.advice.CountingBeforeAdvice"/>
<bean id="countingBeforeAdvice" class="org.springframework.aop.testfixture.advice.CountingBeforeAdvice"/>
<bean id="proxy" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="target">

12
spring-aop/src/test/resources/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests-context.xml

@ -4,12 +4,12 @@ @@ -4,12 +4,12 @@
<beans>
<!-- Simple target -->
<bean id="test" class="org.springframework.tests.sample.beans.TestBean">
<bean id="test" class="org.springframework.beans.testfixture.beans.TestBean">
<property name="name"><value>custom</value></property>
<property name="age"><value>666</value></property>
</bean>
<bean id="nopInterceptor" class="org.springframework.tests.aop.interceptor.SerializableNopInterceptor"/>
<bean id="nopInterceptor" class="org.springframework.aop.testfixture.interceptor.SerializableNopInterceptor"/>
<bean id="settersAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
<property name="advice"><ref bean="nopInterceptor"/></property>
@ -21,15 +21,15 @@ @@ -21,15 +21,15 @@
</bean>
<bean id="settersAdvised" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces"><value>org.springframework.tests.sample.beans.ITestBean</value></property>
<property name="proxyInterfaces"><value>org.springframework.beans.testfixture.beans.ITestBean</value></property>
<property name="target"><ref bean="test"/></property>
<property name="interceptorNames"><value>settersAdvisor</value></property>
</bean>
<bean id="serializableSettersAdvised" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces"><value>org.springframework.tests.sample.beans.Person</value></property>
<property name="proxyInterfaces"><value>org.springframework.beans.testfixture.beans.Person</value></property>
<property name="target">
<bean class="org.springframework.tests.sample.beans.SerializablePerson">
<bean class="org.springframework.beans.testfixture.beans.SerializablePerson">
<property name="name"><value>serializableSettersAdvised</value></property>
</bean>
</property>
@ -48,7 +48,7 @@ @@ -48,7 +48,7 @@
</bean>
<bean id="settersAndAbsquatulateAdvised" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces"><value>org.springframework.tests.sample.beans.ITestBean</value></property>
<property name="proxyInterfaces"><value>org.springframework.beans.testfixture.beans.ITestBean</value></property>
<!-- Force CGLIB so we can cast to TestBean -->
<property name="proxyTargetClass"><value>true</value></property>
<property name="target"><ref bean="test"/></property>

2
spring-aop/src/test/resources/org/springframework/aop/target/CommonsPool2TargetSourceProxyTests-context.xml

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
<beans>
<bean id="testBeanTarget" class="org.springframework.tests.sample.beans.TestBean" scope="prototype"/>
<bean id="testBeanTarget" class="org.springframework.beans.testfixture.beans.TestBean" scope="prototype"/>
<bean id="targetSource" class="org.springframework.aop.target.CommonsPool2TargetSource">
<property name="targetBeanName" value="testBeanTarget"/>

4
spring-aop/src/test/resources/org/springframework/aop/target/HotSwappableTargetSourceTests-context.xml

@ -4,11 +4,11 @@ @@ -4,11 +4,11 @@
<beans>
<!-- Simple target -->
<bean id="target1" class="org.springframework.tests.sample.beans.SideEffectBean">
<bean id="target1" class="org.springframework.beans.testfixture.beans.SideEffectBean">
<property name="count"><value>10</value></property>
</bean>
<bean id="target2" class="org.springframework.tests.sample.beans.SideEffectBean" scope="singleton">
<bean id="target2" class="org.springframework.beans.testfixture.beans.SideEffectBean" scope="singleton">
<property name="count"><value>20</value></property>
</bean>

2
spring-aop/src/test/resources/org/springframework/aop/target/LazyInitTargetSourceTests-customTarget.xml

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
<beans>
<bean id="target" class="org.springframework.tests.sample.beans.TestBean" lazy-init="true">
<bean id="target" class="org.springframework.beans.testfixture.beans.TestBean" lazy-init="true">
<property name="age"><value>10</value></property>
</bean>

2
spring-aop/src/test/resources/org/springframework/aop/target/LazyInitTargetSourceTests-singleton.xml

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
<beans>
<bean id="target" class="org.springframework.tests.sample.beans.TestBean" lazy-init="true">
<bean id="target" class="org.springframework.beans.testfixture.beans.TestBean" lazy-init="true">
<property name="age"><value>10</value></property>
</bean>

6
spring-aop/src/test/resources/org/springframework/aop/target/PrototypeTargetSourceTests-context.xml

@ -4,11 +4,11 @@ @@ -4,11 +4,11 @@
<beans>
<!-- Simple target -->
<bean id="test" class="org.springframework.tests.sample.beans.SideEffectBean">
<bean id="test" class="org.springframework.beans.testfixture.beans.SideEffectBean">
<property name="count"><value>10</value></property>
</bean>
<bean id="prototypeTest" class="org.springframework.tests.sample.beans.SideEffectBean" scope="prototype">
<bean id="prototypeTest" class="org.springframework.beans.testfixture.beans.SideEffectBean" scope="prototype">
<property name="count"><value>10</value></property>
</bean>
@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
<property name="targetBeanName"><value>prototypeTest</value></property>
</bean>
<bean id="debugInterceptor" class="org.springframework.tests.aop.interceptor.NopInterceptor" />
<bean id="debugInterceptor" class="org.springframework.aop.testfixture.interceptor.NopInterceptor" />
<bean id="singleton" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="interceptorNames"><value>debugInterceptor,test</value></property>

8
spring-aop/src/test/resources/org/springframework/aop/target/ThreadLocalTargetSourceTests-context.xml

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
<beans>
<bean id="prototypeTest" class="org.springframework.tests.sample.beans.SideEffectBean" scope="prototype">
<bean id="prototypeTest" class="org.springframework.beans.testfixture.beans.SideEffectBean" scope="prototype">
<property name="count"><value>10</value></property>
</bean>
@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
<property name="targetBeanName"><value>prototypeTest</value></property>
</bean>
<bean id="debugInterceptor" class="org.springframework.tests.aop.interceptor.NopInterceptor" />
<bean id="debugInterceptor" class="org.springframework.aop.testfixture.interceptor.NopInterceptor" />
<!--
We want to invoke the getStatsMixin method on our ThreadLocal invoker
@ -34,12 +34,12 @@ @@ -34,12 +34,12 @@
<!-- ================ Definitions for second ThreadLocalTargetSource ====== -->
<bean id="test" class="org.springframework.tests.sample.beans.TestBean" scope="prototype">
<bean id="test" class="org.springframework.beans.testfixture.beans.TestBean" scope="prototype">
<property name="name"><value>Rod</value></property>
<property name="spouse"><ref bean="wife"/></property>
</bean>
<bean id="wife" class="org.springframework.tests.sample.beans.TestBean">
<bean id="wife" class="org.springframework.beans.testfixture.beans.TestBean">
<property name="name"><value>Kerry</value></property>
</bean>

4
spring-aop/src/test/java/org/springframework/tests/aop/advice/CountingAfterReturningAdvice.java → spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/advice/CountingAfterReturningAdvice.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2019 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.
@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.tests.aop.advice;
package org.springframework.aop.testfixture.advice;
import java.lang.reflect.Method;

4
spring-aop/src/test/java/org/springframework/tests/aop/advice/CountingBeforeAdvice.java → spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/advice/CountingBeforeAdvice.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2019 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.
@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.tests.aop.advice;
package org.springframework.aop.testfixture.advice;
import java.lang.reflect.Method;

4
spring-aop/src/test/java/org/springframework/tests/aop/advice/MethodCounter.java → spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/advice/MethodCounter.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2019 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.
@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.tests.aop.advice;
package org.springframework.aop.testfixture.advice;
import java.io.Serializable;
import java.lang.reflect.Method;

5
spring-aop/src/test/java/org/springframework/tests/aop/advice/MyThrowsHandler.java → spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/advice/MyThrowsHandler.java

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.tests.aop.advice;
package org.springframework.aop.testfixture.advice;
import java.io.IOException;
import java.lang.reflect.Method;
@ -24,10 +24,12 @@ import org.springframework.aop.ThrowsAdvice; @@ -24,10 +24,12 @@ import org.springframework.aop.ThrowsAdvice;
@SuppressWarnings("serial")
public class MyThrowsHandler extends MethodCounter implements ThrowsAdvice {
// Full method signature
public void afterThrowing(Method m, Object[] args, Object target, IOException ex) {
count("ioException");
}
public void afterThrowing(RemoteException ex) throws Throwable {
count("remoteException");
}
@ -36,4 +38,5 @@ public class MyThrowsHandler extends MethodCounter implements ThrowsAdvice { @@ -36,4 +38,5 @@ public class MyThrowsHandler extends MethodCounter implements ThrowsAdvice {
public void afterThrowing(Method m, Exception ex) throws Throwable {
throw new UnsupportedOperationException("Shouldn't be called");
}
}

4
spring-aop/src/test/java/org/springframework/tests/aop/advice/TimestampIntroductionAdvisor.java → spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/advice/TimestampIntroductionAdvisor.java

@ -14,11 +14,11 @@ @@ -14,11 +14,11 @@
* limitations under the License.
*/
package org.springframework.tests.aop.advice;
package org.springframework.aop.testfixture.advice;
import org.springframework.aop.support.DefaultIntroductionAdvisor;
import org.springframework.aop.support.DelegatingIntroductionInterceptor;
import org.springframework.tests.aop.interceptor.TimestampIntroductionInterceptor;
import org.springframework.aop.testfixture.interceptor.TimestampIntroductionInterceptor;
/**
* @author Rod Johnson

2
spring-aop/src/test/java/org/springframework/tests/aop/interceptor/NopInterceptor.java → spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/interceptor/NopInterceptor.java

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.tests.aop.interceptor;
package org.springframework.aop.testfixture.interceptor;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

2
spring-aop/src/test/java/org/springframework/tests/aop/interceptor/SerializableNopInterceptor.java → spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/interceptor/SerializableNopInterceptor.java

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.tests.aop.interceptor;
package org.springframework.aop.testfixture.interceptor;
import java.io.Serializable;

4
spring-aop/src/test/java/org/springframework/tests/aop/interceptor/TimestampIntroductionInterceptor.java → spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/interceptor/TimestampIntroductionInterceptor.java

@ -14,10 +14,10 @@ @@ -14,10 +14,10 @@
* limitations under the License.
*/
package org.springframework.tests.aop.interceptor;
package org.springframework.aop.testfixture.interceptor;
import org.springframework.aop.support.DelegatingIntroductionInterceptor;
import org.springframework.tests.TimeStamped;
import org.springframework.core.testfixture.TimeStamped;
@SuppressWarnings("serial")
public class TimestampIntroductionInterceptor extends DelegatingIntroductionInterceptor

4
spring-aspects/spring-aspects.gradle

@ -24,6 +24,10 @@ dependencies { @@ -24,6 +24,10 @@ dependencies {
optional("javax.transaction:javax.transaction-api") // for @javax.transaction.Transactional support
testCompile(project(":spring-core")) // for CodeStyleAspect
testCompile(project(":spring-test"))
testCompile(testFixtures(project(":spring-context")))
testCompile(testFixtures(project(":spring-context-support")))
testCompile(testFixtures(project(":spring-core")))
testCompile(testFixtures(project(":spring-tx")))
testCompile("javax.mail:javax.mail-api")
testCompileOnly("org.aspectj:aspectjrt")
}

882
spring-aspects/src/test/java/org/springframework/cache/aspectj/AbstractCacheAnnotationTests.java vendored

@ -0,0 +1,882 @@ @@ -0,0 +1,882 @@
/*
* Copyright 2002-2019 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.cache.aspectj;
import java.util.Collection;
import java.util.UUID;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.aop.framework.AopProxyUtils;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.cache.config.AnnotatedClassCacheableService;
import org.springframework.cache.config.CacheableService;
import org.springframework.cache.config.TestEntity;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.testfixture.cache.SomeCustomKeyGenerator;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIOException;
/**
* Copy of the shared {@code AbstractCacheAnnotationTests}: necessary
* due to issues with Gradle test fixtures and AspectJ configuration
* in the Gradle build.
*
* <p>Abstract cache annotation tests (containing several reusable methods).
*
* @author Costin Leau
* @author Chris Beams
* @author Phillip Webb
* @author Stephane Nicoll
*/
public abstract class AbstractCacheAnnotationTests {
protected ConfigurableApplicationContext ctx;
protected CacheableService<?> cs;
protected CacheableService<?> ccs;
protected CacheManager cm;
/**
* @return a refreshed application context
*/
protected abstract ConfigurableApplicationContext getApplicationContext();
@BeforeEach
public void setup() {
this.ctx = getApplicationContext();
this.cs = ctx.getBean("service", CacheableService.class);
this.ccs = ctx.getBean("classService", CacheableService.class);
this.cm = ctx.getBean("cacheManager", CacheManager.class);
Collection<String> cn = this.cm.getCacheNames();
assertThat(cn).containsOnly("testCache", "secondary", "primary");
}
@AfterEach
public void close() {
if (this.ctx != null) {
this.ctx.close();
}
}
protected void testCacheable(CacheableService<?> service) {
Object o1 = new Object();
Object r1 = service.cache(o1);
Object r2 = service.cache(o1);
Object r3 = service.cache(o1);
assertThat(r2).isSameAs(r1);
assertThat(r3).isSameAs(r1);
}
protected void testCacheableNull(CacheableService<?> service) {
Object o1 = new Object();
assertThat(this.cm.getCache("testCache").get(o1)).isNull();
Object r1 = service.cacheNull(o1);
Object r2 = service.cacheNull(o1);
Object r3 = service.cacheNull(o1);
assertThat(r2).isSameAs(r1);
assertThat(r3).isSameAs(r1);
assertThat(this.cm.getCache("testCache")).as("testCache").isNotNull();
assertThat(this.cm.getCache("testCache").get(o1)).as("cached object").isNotNull();
assertThat(this.cm.getCache("testCache").get(o1).get()).isEqualTo(r3);
assertThat(r3).as("Cached value should be null").isNull();
}
protected void testCacheableSync(CacheableService<?> service) {
Object o1 = new Object();
Object r1 = service.cacheSync(o1);
Object r2 = service.cacheSync(o1);
Object r3 = service.cacheSync(o1);
assertThat(r2).isSameAs(r1);
assertThat(r3).isSameAs(r1);
}
protected void testCacheableSyncNull(CacheableService<?> service) {
Object o1 = new Object();
assertThat(this.cm.getCache("testCache").get(o1)).isNull();
Object r1 = service.cacheSyncNull(o1);
Object r2 = service.cacheSyncNull(o1);
Object r3 = service.cacheSyncNull(o1);
assertThat(r2).isSameAs(r1);
assertThat(r3).isSameAs(r1);
assertThat(this.cm.getCache("testCache").get(o1).get()).isEqualTo(r3);
assertThat(r3).as("Cached value should be null").isNull();
}
protected void testEvict(CacheableService<?> service, boolean successExpected) {
Cache cache = this.cm.getCache("testCache");
Object o1 = new Object();
cache.putIfAbsent(o1, -1L);
Object r1 = service.cache(o1);
service.evict(o1, null);
if (successExpected) {
assertThat(cache.get(o1)).isNull();
}
else {
assertThat(cache.get(o1)).isNotNull();
}
Object r2 = service.cache(o1);
if (successExpected) {
assertThat(r2).isNotSameAs(r1);
}
else {
assertThat(r2).isSameAs(r1);
}
}
protected void testEvictEarly(CacheableService<?> service) {
Cache cache = this.cm.getCache("testCache");
Object o1 = new Object();
cache.putIfAbsent(o1, -1L);
Object r1 = service.cache(o1);
try {
service.evictEarly(o1);
}
catch (RuntimeException ex) {
// expected
}
assertThat(cache.get(o1)).isNull();
Object r2 = service.cache(o1);
assertThat(r2).isNotSameAs(r1);
}
protected void testEvictException(CacheableService<?> service) {
Object o1 = new Object();
Object r1 = service.cache(o1);
try {
service.evictWithException(o1);
}
catch (RuntimeException ex) {
// expected
}
// exception occurred, eviction skipped, data should still be in the cache
Object r2 = service.cache(o1);
assertThat(r2).isSameAs(r1);
}
protected void testEvictWithKey(CacheableService<?> service) {
Object o1 = new Object();
Object r1 = service.cache(o1);
service.evict(o1, null);
Object r2 = service.cache(o1);
assertThat(r2).isNotSameAs(r1);
}
protected void testEvictWithKeyEarly(CacheableService<?> service) {
Object o1 = new Object();
Object r1 = service.cache(o1);
try {
service.evictEarly(o1);
}
catch (Exception ex) {
// expected
}
Object r2 = service.cache(o1);
assertThat(r2).isNotSameAs(r1);
}
protected void testEvictAll(CacheableService<?> service, boolean successExpected) {
Cache cache = this.cm.getCache("testCache");
Object o1 = new Object();
Object o2 = new Object();
cache.putIfAbsent(o1, -1L);
cache.putIfAbsent(o2, -2L);
Object r1 = service.cache(o1);
Object r2 = service.cache(o2);
assertThat(r2).isNotSameAs(r1);
service.evictAll(new Object());
if (successExpected) {
assertThat(cache.get(o1)).isNull();
assertThat(cache.get(o2)).isNull();
}
else {
assertThat(cache.get(o1)).isNotNull();
assertThat(cache.get(o2)).isNotNull();
}
Object r3 = service.cache(o1);
Object r4 = service.cache(o2);
if (successExpected) {
assertThat(r3).isNotSameAs(r1);
assertThat(r4).isNotSameAs(r2);
}
else {
assertThat(r3).isSameAs(r1);
assertThat(r4).isSameAs(r2);
}
}
protected void testEvictAllEarly(CacheableService<?> service) {
Cache cache = this.cm.getCache("testCache");
Object o1 = new Object();
Object o2 = new Object();
cache.putIfAbsent(o1, -1L);
cache.putIfAbsent(o2, -2L);
Object r1 = service.cache(o1);
Object r2 = service.cache(o2);
assertThat(r2).isNotSameAs(r1);
try {
service.evictAllEarly(new Object());
}
catch (Exception ex) {
// expected
}
assertThat(cache.get(o1)).isNull();
assertThat(cache.get(o2)).isNull();
Object r3 = service.cache(o1);
Object r4 = service.cache(o2);
assertThat(r3).isNotSameAs(r1);
assertThat(r4).isNotSameAs(r2);
}
protected void testConditionalExpression(CacheableService<?> service) {
Object r1 = service.conditional(4);
Object r2 = service.conditional(4);
assertThat(r2).isNotSameAs(r1);
Object r3 = service.conditional(3);
Object r4 = service.conditional(3);
assertThat(r4).isSameAs(r3);
}
protected void testConditionalExpressionSync(CacheableService<?> service) {
Object r1 = service.conditionalSync(4);
Object r2 = service.conditionalSync(4);
assertThat(r2).isNotSameAs(r1);
Object r3 = service.conditionalSync(3);
Object r4 = service.conditionalSync(3);
assertThat(r4).isSameAs(r3);
}
protected void testUnlessExpression(CacheableService<?> service) {
Cache cache = this.cm.getCache("testCache");
cache.clear();
service.unless(10);
service.unless(11);
assertThat(cache.get(10).get()).isEqualTo(10L);
assertThat(cache.get(11)).isNull();
}
protected void testKeyExpression(CacheableService<?> service) {
Object r1 = service.key(5, 1);
Object r2 = service.key(5, 2);
assertThat(r2).isSameAs(r1);
Object r3 = service.key(1, 5);
Object r4 = service.key(2, 5);
assertThat(r4).isNotSameAs(r3);
}
protected void testVarArgsKey(CacheableService<?> service) {
Object r1 = service.varArgsKey(1, 2, 3);
Object r2 = service.varArgsKey(1, 2, 3);
assertThat(r2).isSameAs(r1);
Object r3 = service.varArgsKey(1, 2, 3);
Object r4 = service.varArgsKey(1, 2);
assertThat(r4).isNotSameAs(r3);
}
protected void testNullValue(CacheableService<?> service) {
Object key = new Object();
assertThat(service.nullValue(key)).isNull();
int nr = service.nullInvocations().intValue();
assertThat(service.nullValue(key)).isNull();
assertThat(service.nullInvocations().intValue()).isEqualTo(nr);
assertThat(service.nullValue(new Object())).isNull();
assertThat(service.nullInvocations().intValue()).isEqualTo(nr + 1);
}
protected void testMethodName(CacheableService<?> service, String keyName) {
Object key = new Object();
Object r1 = service.name(key);
assertThat(service.name(key)).isSameAs(r1);
Cache cache = this.cm.getCache("testCache");
// assert the method name is used
assertThat(cache.get(keyName)).isNotNull();
}
protected void testRootVars(CacheableService<?> service) {
Object key = new Object();
Object r1 = service.rootVars(key);
assertThat(service.rootVars(key)).isSameAs(r1);
Cache cache = this.cm.getCache("testCache");
// assert the method name is used
String expectedKey = "rootVarsrootVars" + AopProxyUtils.ultimateTargetClass(service) + service;
assertThat(cache.get(expectedKey)).isNotNull();
}
protected void testCheckedThrowable(CacheableService<?> service) {
String arg = UUID.randomUUID().toString();
assertThatIOException().isThrownBy(() ->
service.throwChecked(arg))
.withMessage(arg);
}
protected void testUncheckedThrowable(CacheableService<?> service) {
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() ->
service.throwUnchecked(1L))
.withMessage("1");
}
protected void testCheckedThrowableSync(CacheableService<?> service) {
String arg = UUID.randomUUID().toString();
assertThatIOException().isThrownBy(() ->
service.throwCheckedSync(arg))
.withMessage(arg);
}
protected void testUncheckedThrowableSync(CacheableService<?> service) {
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() ->
service.throwUncheckedSync(1L))
.withMessage("1");
}
protected void testNullArg(CacheableService<?> service) {
Object r1 = service.cache(null);
assertThat(service.cache(null)).isSameAs(r1);
}
protected void testCacheUpdate(CacheableService<?> service) {
Object o = new Object();
Cache cache = this.cm.getCache("testCache");
assertThat(cache.get(o)).isNull();
Object r1 = service.update(o);
assertThat(cache.get(o).get()).isSameAs(r1);
o = new Object();
assertThat(cache.get(o)).isNull();
Object r2 = service.update(o);
assertThat(cache.get(o).get()).isSameAs(r2);
}
protected void testConditionalCacheUpdate(CacheableService<?> service) {
Integer one = 1;
Integer three = 3;
Cache cache = this.cm.getCache("testCache");
assertThat((int) Integer.valueOf(service.conditionalUpdate(one).toString())).isEqualTo((int) one);
assertThat(cache.get(one)).isNull();
assertThat((int) Integer.valueOf(service.conditionalUpdate(three).toString())).isEqualTo((int) three);
assertThat((int) Integer.valueOf(cache.get(three).get().toString())).isEqualTo((int) three);
}
protected void testMultiCache(CacheableService<?> service) {
Object o1 = new Object();
Object o2 = new Object();
Cache primary = this.cm.getCache("primary");
Cache secondary = this.cm.getCache("secondary");
assertThat(primary.get(o1)).isNull();
assertThat(secondary.get(o1)).isNull();
Object r1 = service.multiCache(o1);
assertThat(primary.get(o1).get()).isSameAs(r1);
assertThat(secondary.get(o1).get()).isSameAs(r1);
Object r2 = service.multiCache(o1);
Object r3 = service.multiCache(o1);
assertThat(r2).isSameAs(r1);
assertThat(r3).isSameAs(r1);
assertThat(primary.get(o2)).isNull();
assertThat(secondary.get(o2)).isNull();
Object r4 = service.multiCache(o2);
assertThat(primary.get(o2).get()).isSameAs(r4);
assertThat(secondary.get(o2).get()).isSameAs(r4);
}
protected void testMultiEvict(CacheableService<?> service) {
Object o1 = new Object();
Object o2 = o1.toString() + "A";
Object r1 = service.multiCache(o1);
Object r2 = service.multiCache(o1);
Cache primary = this.cm.getCache("primary");
Cache secondary = this.cm.getCache("secondary");
primary.put(o2, o2);
assertThat(r2).isSameAs(r1);
assertThat(primary.get(o1).get()).isSameAs(r1);
assertThat(secondary.get(o1).get()).isSameAs(r1);
service.multiEvict(o1);
assertThat(primary.get(o1)).isNull();
assertThat(secondary.get(o1)).isNull();
assertThat(primary.get(o2)).isNull();
Object r3 = service.multiCache(o1);
Object r4 = service.multiCache(o1);
assertThat(r3).isNotSameAs(r1);
assertThat(r4).isSameAs(r3);
assertThat(primary.get(o1).get()).isSameAs(r3);
assertThat(secondary.get(o1).get()).isSameAs(r4);
}
protected void testMultiPut(CacheableService<?> service) {
Object o = 1;
Cache primary = this.cm.getCache("primary");
Cache secondary = this.cm.getCache("secondary");
assertThat(primary.get(o)).isNull();
assertThat(secondary.get(o)).isNull();
Object r1 = service.multiUpdate(o);
assertThat(primary.get(o).get()).isSameAs(r1);
assertThat(secondary.get(o).get()).isSameAs(r1);
o = 2;
assertThat(primary.get(o)).isNull();
assertThat(secondary.get(o)).isNull();
Object r2 = service.multiUpdate(o);
assertThat(primary.get(o).get()).isSameAs(r2);
assertThat(secondary.get(o).get()).isSameAs(r2);
}
protected void testPutRefersToResult(CacheableService<?> service) {
Long id = Long.MIN_VALUE;
TestEntity entity = new TestEntity();
Cache primary = this.cm.getCache("primary");
assertThat(primary.get(id)).isNull();
assertThat(entity.getId()).isNull();
service.putRefersToResult(entity);
assertThat(primary.get(id).get()).isSameAs(entity);
}
protected void testMultiCacheAndEvict(CacheableService<?> service) {
String methodName = "multiCacheAndEvict";
Cache primary = this.cm.getCache("primary");
Cache secondary = this.cm.getCache("secondary");
Object key = 1;
secondary.put(key, key);
assertThat(secondary.get(methodName)).isNull();
assertThat(secondary.get(key).get()).isSameAs(key);
Object r1 = service.multiCacheAndEvict(key);
assertThat(service.multiCacheAndEvict(key)).isSameAs(r1);
// assert the method name is used
assertThat(primary.get(methodName).get()).isSameAs(r1);
assertThat(secondary.get(methodName)).isNull();
assertThat(secondary.get(key)).isNull();
}
protected void testMultiConditionalCacheAndEvict(CacheableService<?> service) {
Cache primary = this.cm.getCache("primary");
Cache secondary = this.cm.getCache("secondary");
Object key = 1;
secondary.put(key, key);
assertThat(primary.get(key)).isNull();
assertThat(secondary.get(key).get()).isSameAs(key);
Object r1 = service.multiConditionalCacheAndEvict(key);
Object r3 = service.multiConditionalCacheAndEvict(key);
assertThat(!r1.equals(r3)).isTrue();
assertThat(primary.get(key)).isNull();
Object key2 = 3;
Object r2 = service.multiConditionalCacheAndEvict(key2);
assertThat(service.multiConditionalCacheAndEvict(key2)).isSameAs(r2);
// assert the method name is used
assertThat(primary.get(key2).get()).isSameAs(r2);
assertThat(secondary.get(key2)).isNull();
}
@Test
public void testCacheable() {
testCacheable(this.cs);
}
@Test
public void testCacheableNull() {
testCacheableNull(this.cs);
}
@Test
public void testCacheableSync() {
testCacheableSync(this.cs);
}
@Test
public void testCacheableSyncNull() {
testCacheableSyncNull(this.cs);
}
@Test
public void testEvict() {
testEvict(this.cs, true);
}
@Test
public void testEvictEarly() {
testEvictEarly(this.cs);
}
@Test
public void testEvictWithException() {
testEvictException(this.cs);
}
@Test
public void testEvictAll() {
testEvictAll(this.cs, true);
}
@Test
public void testEvictAllEarly() {
testEvictAllEarly(this.cs);
}
@Test
public void testEvictWithKey() {
testEvictWithKey(this.cs);
}
@Test
public void testEvictWithKeyEarly() {
testEvictWithKeyEarly(this.cs);
}
@Test
public void testConditionalExpression() {
testConditionalExpression(this.cs);
}
@Test
public void testConditionalExpressionSync() {
testConditionalExpressionSync(this.cs);
}
@Test
public void testUnlessExpression() {
testUnlessExpression(this.cs);
}
@Test
public void testClassCacheUnlessExpression() {
testUnlessExpression(this.cs);
}
@Test
public void testKeyExpression() {
testKeyExpression(this.cs);
}
@Test
public void testVarArgsKey() {
testVarArgsKey(this.cs);
}
@Test
public void testClassCacheCacheable() {
testCacheable(this.ccs);
}
@Test
public void testClassCacheEvict() {
testEvict(this.ccs, true);
}
@Test
public void testClassEvictEarly() {
testEvictEarly(this.ccs);
}
@Test
public void testClassEvictAll() {
testEvictAll(this.ccs, true);
}
@Test
public void testClassEvictWithException() {
testEvictException(this.ccs);
}
@Test
public void testClassCacheEvictWithWKey() {
testEvictWithKey(this.ccs);
}
@Test
public void testClassEvictWithKeyEarly() {
testEvictWithKeyEarly(this.ccs);
}
@Test
public void testNullValue() {
testNullValue(this.cs);
}
@Test
public void testClassNullValue() {
Object key = new Object();
assertThat(this.ccs.nullValue(key)).isNull();
int nr = this.ccs.nullInvocations().intValue();
assertThat(this.ccs.nullValue(key)).isNull();
assertThat(this.ccs.nullInvocations().intValue()).isEqualTo(nr);
assertThat(this.ccs.nullValue(new Object())).isNull();
// the check method is also cached
assertThat(this.ccs.nullInvocations().intValue()).isEqualTo(nr);
assertThat(AnnotatedClassCacheableService.nullInvocations.intValue()).isEqualTo(nr + 1);
}
@Test
public void testMethodName() {
testMethodName(this.cs, "name");
}
@Test
public void testClassMethodName() {
testMethodName(this.ccs, "nametestCache");
}
@Test
public void testRootVars() {
testRootVars(this.cs);
}
@Test
public void testClassRootVars() {
testRootVars(this.ccs);
}
@Test
public void testCustomKeyGenerator() {
Object param = new Object();
Object r1 = this.cs.customKeyGenerator(param);
assertThat(this.cs.customKeyGenerator(param)).isSameAs(r1);
Cache cache = this.cm.getCache("testCache");
// Checks that the custom keyGenerator was used
Object expectedKey = SomeCustomKeyGenerator.generateKey("customKeyGenerator", param);
assertThat(cache.get(expectedKey)).isNotNull();
}
@Test
public void testUnknownCustomKeyGenerator() {
Object param = new Object();
assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() ->
this.cs.unknownCustomKeyGenerator(param));
}
@Test
public void testCustomCacheManager() {
CacheManager customCm = this.ctx.getBean("customCacheManager", CacheManager.class);
Object key = new Object();
Object r1 = this.cs.customCacheManager(key);
assertThat(this.cs.customCacheManager(key)).isSameAs(r1);
Cache cache = customCm.getCache("testCache");
assertThat(cache.get(key)).isNotNull();
}
@Test
public void testUnknownCustomCacheManager() {
Object param = new Object();
assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() ->
this.cs.unknownCustomCacheManager(param));
}
@Test
public void testNullArg() {
testNullArg(this.cs);
}
@Test
public void testClassNullArg() {
testNullArg(this.ccs);
}
@Test
public void testCheckedException() {
testCheckedThrowable(this.cs);
}
@Test
public void testClassCheckedException() {
testCheckedThrowable(this.ccs);
}
@Test
public void testCheckedExceptionSync() {
testCheckedThrowableSync(this.cs);
}
@Test
public void testClassCheckedExceptionSync() {
testCheckedThrowableSync(this.ccs);
}
@Test
public void testUncheckedException() {
testUncheckedThrowable(this.cs);
}
@Test
public void testClassUncheckedException() {
testUncheckedThrowable(this.ccs);
}
@Test
public void testUncheckedExceptionSync() {
testUncheckedThrowableSync(this.cs);
}
@Test
public void testClassUncheckedExceptionSync() {
testUncheckedThrowableSync(this.ccs);
}
@Test
public void testUpdate() {
testCacheUpdate(this.cs);
}
@Test
public void testClassUpdate() {
testCacheUpdate(this.ccs);
}
@Test
public void testConditionalUpdate() {
testConditionalCacheUpdate(this.cs);
}
@Test
public void testClassConditionalUpdate() {
testConditionalCacheUpdate(this.ccs);
}
@Test
public void testMultiCache() {
testMultiCache(this.cs);
}
@Test
public void testClassMultiCache() {
testMultiCache(this.ccs);
}
@Test
public void testMultiEvict() {
testMultiEvict(this.cs);
}
@Test
public void testClassMultiEvict() {
testMultiEvict(this.ccs);
}
@Test
public void testMultiPut() {
testMultiPut(this.cs);
}
@Test
public void testClassMultiPut() {
testMultiPut(this.ccs);
}
@Test
public void testPutRefersToResult() {
testPutRefersToResult(this.cs);
}
@Test
public void testClassPutRefersToResult() {
testPutRefersToResult(this.ccs);
}
@Test
public void testMultiCacheAndEvict() {
testMultiCacheAndEvict(this.cs);
}
@Test
public void testClassMultiCacheAndEvict() {
testMultiCacheAndEvict(this.ccs);
}
@Test
public void testMultiConditionalCacheAndEvict() {
testMultiConditionalCacheAndEvict(this.cs);
}
@Test
public void testClassMultiConditionalCacheAndEvict() {
testMultiConditionalCacheAndEvict(this.ccs);
}
}

1
spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJCacheAnnotationTests.java vendored

@ -19,7 +19,6 @@ package org.springframework.cache.aspectj; @@ -19,7 +19,6 @@ package org.springframework.cache.aspectj;
import org.junit.jupiter.api.Test;
import org.springframework.cache.Cache;
import org.springframework.cache.config.AbstractCacheAnnotationTests;
import org.springframework.cache.config.CacheableService;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;

12
spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJEnableCachingIsolatedTests.java vendored

@ -22,14 +22,8 @@ import org.junit.jupiter.api.Test; @@ -22,14 +22,8 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.cache.CacheManager;
import org.springframework.cache.CacheTestUtils;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.config.AnnotatedClassCacheableService;
import org.springframework.cache.config.CacheableService;
import org.springframework.cache.config.DefaultCacheableService;
import org.springframework.cache.config.SomeCustomKeyGenerator;
import org.springframework.cache.config.SomeKeyGenerator;
import org.springframework.cache.interceptor.CacheErrorHandler;
import org.springframework.cache.interceptor.CacheResolver;
import org.springframework.cache.interceptor.KeyGenerator;
@ -42,6 +36,12 @@ import org.springframework.context.annotation.AdviceMode; @@ -42,6 +36,12 @@ import org.springframework.context.annotation.AdviceMode;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.testfixture.cache.CacheTestUtils;
import org.springframework.context.testfixture.cache.SomeCustomKeyGenerator;
import org.springframework.context.testfixture.cache.SomeKeyGenerator;
import org.springframework.context.testfixture.cache.beans.AnnotatedClassCacheableService;
import org.springframework.context.testfixture.cache.beans.CacheableService;
import org.springframework.context.testfixture.cache.beans.DefaultCacheableService;
import static org.assertj.core.api.Assertions.assertThat;

9
spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJEnableCachingTests.java vendored

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2019 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.
@ -17,15 +17,11 @@ @@ -17,15 +17,11 @@
package org.springframework.cache.aspectj;
import org.springframework.cache.CacheManager;
import org.springframework.cache.CacheTestUtils;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.config.AbstractCacheAnnotationTests;
import org.springframework.cache.config.AnnotatedClassCacheableService;
import org.springframework.cache.config.CacheableService;
import org.springframework.cache.config.DefaultCacheableService;
import org.springframework.cache.config.SomeCustomKeyGenerator;
import org.springframework.cache.config.SomeKeyGenerator;
import org.springframework.cache.interceptor.CacheErrorHandler;
import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.cache.interceptor.SimpleCacheErrorHandler;
@ -34,6 +30,9 @@ import org.springframework.context.annotation.AdviceMode; @@ -34,6 +30,9 @@ import org.springframework.context.annotation.AdviceMode;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.testfixture.cache.CacheTestUtils;
import org.springframework.context.testfixture.cache.SomeCustomKeyGenerator;
import org.springframework.context.testfixture.cache.SomeKeyGenerator;
/**
* @author Stephane Nicoll

2
spring-aspects/src/test/java/org/springframework/cache/aspectj/JCacheAspectJJavaConfigTests.java vendored

@ -23,13 +23,13 @@ import org.springframework.cache.CacheManager; @@ -23,13 +23,13 @@ import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.concurrent.ConcurrentMapCache;
import org.springframework.cache.config.AnnotatedJCacheableService;
import org.springframework.cache.jcache.config.AbstractJCacheAnnotationTests;
import org.springframework.cache.support.SimpleCacheManager;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AdviceMode;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.contextsupport.testfixture.jcache.AbstractJCacheAnnotationTests;
/**
* @author Stephane Nicoll

2
spring-aspects/src/test/java/org/springframework/cache/aspectj/JCacheAspectJNamespaceConfigTests.java vendored

@ -16,9 +16,9 @@ @@ -16,9 +16,9 @@
package org.springframework.cache.aspectj;
import org.springframework.cache.jcache.config.AbstractJCacheAnnotationTests;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;
import org.springframework.contextsupport.testfixture.jcache.AbstractJCacheAnnotationTests;
/**
* @author Stephane Nicoll

4
spring-aspects/src/test/java/org/springframework/cache/config/AnnotatedClassCacheableService.java vendored

@ -25,6 +25,10 @@ import org.springframework.cache.annotation.Cacheable; @@ -25,6 +25,10 @@ import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.Caching;
/**
* Copy of the shared {@code AbstractCacheAnnotationTests}: necessary
* due to issues with Gradle test fixtures and AspectJ configuration
* in the Gradle build.
*
* @author Costin Leau
* @author Phillip Webb
* @author Stephane Nicoll

6
spring-aspects/src/test/java/org/springframework/cache/config/AnnotatedJCacheableService.java vendored

@ -30,9 +30,9 @@ import javax.cache.annotation.CacheValue; @@ -30,9 +30,9 @@ import javax.cache.annotation.CacheValue;
import org.springframework.cache.Cache;
import org.springframework.cache.interceptor.SimpleKeyGenerator;
import org.springframework.cache.jcache.config.JCacheableService;
import org.springframework.cache.jcache.support.TestableCacheKeyGenerator;
import org.springframework.cache.jcache.support.TestableCacheResolverFactory;
import org.springframework.contextsupport.testfixture.cache.TestableCacheKeyGenerator;
import org.springframework.contextsupport.testfixture.cache.TestableCacheResolverFactory;
import org.springframework.contextsupport.testfixture.jcache.JCacheableService;
/**
* Repository sample with a @CacheDefaults annotation

6
spring-aspects/src/test/java/org/springframework/cache/config/CacheableService.java vendored

@ -17,7 +17,11 @@ @@ -17,7 +17,11 @@
package org.springframework.cache.config;
/**
* Basic service interface for caching tests.
* Copy of the shared {@code CacheableService}: necessary
* due to issues with Gradle test fixtures and AspectJ configuration
* in the Gradle build.
*
* <p>Basic service interface for caching tests.
*
* @author Costin Leau
* @author Phillip Webb

6
spring-aspects/src/test/java/org/springframework/cache/config/DefaultCacheableService.java vendored

@ -25,7 +25,11 @@ import org.springframework.cache.annotation.Cacheable; @@ -25,7 +25,11 @@ import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.Caching;
/**
* Simple cacheable service.
* Copy of the shared {@code DefaultCacheableService}: necessary
* due to issues with Gradle test fixtures and AspectJ configuration
* in the Gradle build.
*
* <p>Simple cacheable service.
*
* @author Costin Leau
* @author Phillip Webb

22
spring-aspects/src/test/java/org/springframework/cache/config/SomeKeyGenerator.java vendored

@ -1,22 +0,0 @@ @@ -1,22 +0,0 @@
/*
* Copyright 2002-2016 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.cache.config;
import org.springframework.cache.interceptor.SimpleKeyGenerator;
public class SomeKeyGenerator extends SimpleKeyGenerator {
}

9
spring-aspects/src/test/java/org/springframework/cache/config/TestEntity.java vendored

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2019 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.
@ -19,7 +19,11 @@ package org.springframework.cache.config; @@ -19,7 +19,11 @@ package org.springframework.cache.config;
import org.springframework.util.ObjectUtils;
/**
* Simple test entity for use with caching tests.
* Copy of the shared {@code TestEntity}: necessary
* due to issues with Gradle test fixtures and AspectJ configuration
* in the Gradle build.
*
* <p>Simple test entity for use with caching tests.
*
* @author Michael Plod
*/
@ -53,5 +57,4 @@ public class TestEntity { @@ -53,5 +57,4 @@ public class TestEntity {
}
return false;
}
}

4
spring-aspects/src/test/java/org/springframework/scheduling/aspectj/AnnotationAsyncExecutionAspectTests.java

@ -30,15 +30,15 @@ import org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler; @@ -30,15 +30,15 @@ import org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.core.testfixture.EnabledForTestGroups;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.tests.EnabledForTestGroups;
import org.springframework.util.ReflectionUtils;
import org.springframework.util.concurrent.ListenableFuture;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.tests.TestGroup.PERFORMANCE;
import static org.springframework.core.testfixture.TestGroup.PERFORMANCE;
/**
* Unit tests for {@link AnnotationAsyncExecutionAspect}.

2
spring-aspects/src/test/java/org/springframework/transaction/aspectj/JtaTransactionAspectsTests.java

@ -27,7 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired; @@ -27,7 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.tests.transaction.CallCountingTransactionManager;
import org.springframework.transaction.testfixture.CallCountingTransactionManager;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

2
spring-aspects/src/test/java/org/springframework/transaction/aspectj/TransactionAspectTests.java

@ -19,7 +19,7 @@ package org.springframework.transaction.aspectj; @@ -19,7 +19,7 @@ package org.springframework.transaction.aspectj;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.tests.transaction.CallCountingTransactionManager;
import org.springframework.transaction.testfixture.CallCountingTransactionManager;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

4
spring-aspects/src/test/resources/org/springframework/cache/config/annotation-cache-aspectj.xml vendored

@ -22,7 +22,7 @@ @@ -22,7 +22,7 @@
<cache:annotation-driven mode="aspectj" key-generator="keyGenerator"/>
<bean id="keyGenerator" class="org.springframework.cache.config.SomeKeyGenerator"/>
<bean id="keyGenerator" class="org.springframework.context.testfixture.cache.SomeKeyGenerator"/>
<bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager">
<property name="caches">
@ -40,7 +40,7 @@ @@ -40,7 +40,7 @@
</property>
</bean>
<bean id="customKeyGenerator" class="org.springframework.cache.config.SomeCustomKeyGenerator"/>
<bean id="customKeyGenerator" class="org.springframework.context.testfixture.cache.SomeCustomKeyGenerator"/>
<bean id="customCacheManager" class="org.springframework.cache.support.SimpleCacheManager">
<property name="caches">

3
spring-beans/spring-beans.gradle

@ -10,7 +10,10 @@ dependencies { @@ -10,7 +10,10 @@ dependencies {
optional("org.codehaus.groovy:groovy-xml")
optional("org.jetbrains.kotlin:kotlin-reflect")
optional("org.jetbrains.kotlin:kotlin-stdlib")
testCompile(testFixtures(project(":spring-core")))
testCompile("javax.annotation:javax.annotation-api")
testFixturesApi("org.junit.jupiter:junit-jupiter-api")
testFixturesImplementation("org.assertj:assertj-core")
}
// This module does joint compilation for Java and Groovy code with the compileGroovy task.

16
spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java

@ -43,18 +43,18 @@ import org.springframework.beans.propertyeditors.CustomNumberEditor; @@ -43,18 +43,18 @@ import org.springframework.beans.propertyeditors.CustomNumberEditor;
import org.springframework.beans.propertyeditors.StringArrayPropertyEditor;
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
import org.springframework.beans.support.DerivedFromProtectedBaseBean;
import org.springframework.beans.testfixture.beans.BooleanTestBean;
import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.beans.testfixture.beans.IndexedTestBean;
import org.springframework.beans.testfixture.beans.NumberTestBean;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.core.convert.ConversionFailedException;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.core.testfixture.Assume;
import org.springframework.core.testfixture.EnabledForTestGroups;
import org.springframework.lang.Nullable;
import org.springframework.tests.Assume;
import org.springframework.tests.EnabledForTestGroups;
import org.springframework.tests.sample.beans.BooleanTestBean;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.IndexedTestBean;
import org.springframework.tests.sample.beans.NumberTestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.util.StopWatch;
import org.springframework.util.StringUtils;
@ -62,7 +62,7 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -62,7 +62,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.within;
import static org.springframework.tests.TestGroup.PERFORMANCE;
import static org.springframework.core.testfixture.TestGroup.PERFORMANCE;
/**
* Shared tests for property accessors.

6
spring-beans/src/test/java/org/springframework/beans/BeanUtilsTests.java

@ -34,12 +34,12 @@ import org.junit.jupiter.params.provider.ValueSource; @@ -34,12 +34,12 @@ import org.junit.jupiter.params.provider.ValueSource;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.beans.testfixture.beans.DerivedTestBean;
import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceEditor;
import org.springframework.lang.Nullable;
import org.springframework.tests.sample.beans.DerivedTestBean;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

4
spring-beans/src/test/java/org/springframework/beans/BeanWrapperEnumTests.java

@ -21,9 +21,9 @@ import java.util.Map; @@ -21,9 +21,9 @@ import java.util.Map;
import org.junit.jupiter.api.Test;
import org.springframework.beans.testfixture.beans.CustomEnum;
import org.springframework.beans.testfixture.beans.GenericBean;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.tests.sample.beans.CustomEnum;
import org.springframework.tests.sample.beans.GenericBean;
import static org.assertj.core.api.Assertions.assertThat;

8
spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java

@ -33,11 +33,11 @@ import org.junit.jupiter.api.Test; @@ -33,11 +33,11 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.propertyeditors.CustomNumberEditor;
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
import org.springframework.beans.testfixture.beans.GenericBean;
import org.springframework.beans.testfixture.beans.GenericIntegerBean;
import org.springframework.beans.testfixture.beans.GenericSetOfIntegerBean;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.core.io.UrlResource;
import org.springframework.tests.sample.beans.GenericBean;
import org.springframework.tests.sample.beans.GenericIntegerBean;
import org.springframework.tests.sample.beans.GenericSetOfIntegerBean;
import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

2
spring-beans/src/test/java/org/springframework/beans/BeanWrapperTests.java

@ -22,7 +22,7 @@ import java.util.Optional; @@ -22,7 +22,7 @@ import java.util.Optional;
import org.junit.jupiter.api.Test;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.testfixture.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

4
spring-beans/src/test/java/org/springframework/beans/CachedIntrospectionResultsTests.java

@ -22,8 +22,8 @@ import java.util.ArrayList; @@ -22,8 +22,8 @@ import java.util.ArrayList;
import org.junit.jupiter.api.Test;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.core.OverridingClassLoader;
import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
@ -42,7 +42,7 @@ public class CachedIntrospectionResultsTests { @@ -42,7 +42,7 @@ public class CachedIntrospectionResultsTests {
assertThat(CachedIntrospectionResults.strongClassCache.containsKey(TestBean.class)).isTrue();
ClassLoader child = new OverridingClassLoader(getClass().getClassLoader());
Class<?> tbClass = child.loadClass("org.springframework.tests.sample.beans.TestBean");
Class<?> tbClass = child.loadClass("org.springframework.beans.testfixture.beans.TestBean");
assertThat(CachedIntrospectionResults.strongClassCache.containsKey(tbClass)).isFalse();
CachedIntrospectionResults.acceptClassLoader(child);
bw = new BeanWrapperImpl(tbClass);

2
spring-beans/src/test/java/org/springframework/beans/DirectFieldAccessorTests.java

@ -18,7 +18,7 @@ package org.springframework.beans; @@ -18,7 +18,7 @@ package org.springframework.beans;
import org.junit.jupiter.api.Test;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.testfixture.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;

2
spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java

@ -25,7 +25,7 @@ import java.math.BigDecimal; @@ -25,7 +25,7 @@ import java.math.BigDecimal;
import org.junit.jupiter.api.Test;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.testfixture.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;

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

Loading…
Cancel
Save