Browse Source

Merge branch '3.2.x' into master

Conflicts:
	gradle.properties
	spring-beans/src/main/java/org/springframework/beans/factory/support/StaticListableBeanFactory.java
	spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheManagerFactoryBean.java
	spring-core/src/main/java/org/springframework/core/convert/support/StringToEnumConverterFactory.java
	spring-core/src/main/java/org/springframework/core/env/ReadOnlySystemAttributesMap.java
	spring-jdbc/src/main/java/org/springframework/jdbc/datasource/LazyConnectionDataSourceProxy.java
	spring-jdbc/src/main/java/org/springframework/jdbc/support/lob/AbstractLobHandler.java
	spring-web/src/main/java/org/springframework/http/client/BufferingClientHttpRequestWrapper.java
	spring-web/src/main/java/org/springframework/http/client/SimpleBufferingClientHttpRequest.java
	spring-web/src/main/java/org/springframework/http/converter/BufferedImageHttpMessageConverter.java
	spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java
pull/249/head
Chris Beams 13 years ago
parent
commit
ce4be3b46b
  1. 7
      .gitignore
  2. 8
      CONTRIBUTING.md
  3. 81
      build.gradle
  4. 158
      buildSrc/src/main/groovy/org/springframework/build/gradle/DetectSplitPackagesPlugin.groovy
  5. 12
      buildSrc/src/main/groovy/org/springframework/build/gradle/MergePlugin.groovy
  6. 2
      buildSrc/src/main/groovy/org/springframework/build/gradle/TestSourceSetDependenciesPlugin.groovy
  7. 1
      buildSrc/src/main/resources/META-INF/gradle-plugins/detect-split-packages.properties
  8. 80
      gradle/ide.gradle
  9. 5
      gradle/publish-maven.gradle
  10. 4
      spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java
  11. 4
      spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJProxyUtils.java
  12. 4
      spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/InstantiationModelAwarePointcutAdvisorImpl.java
  13. 27
      spring-aop/src/main/java/org/springframework/aop/aspectj/autoproxy/AspectJAwareAdvisorAutoProxyCreator.java
  14. 21
      spring-aop/src/main/java/org/springframework/aop/aspectj/autoproxy/AspectJPrecedenceComparator.java
  15. 14
      spring-aop/src/main/java/org/springframework/aop/framework/AbstractAdvisingBeanPostProcessor.java
  16. 4
      spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java
  17. 33
      spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionAspectSupport.java
  18. 20
      spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionInterceptor.java
  19. 2
      spring-aop/src/main/java/org/springframework/aop/support/DelegatingIntroductionInterceptor.java
  20. 32
      spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutTests.java
  21. 4
      spring-aop/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutMatchingTests.java
  22. 10
      spring-aop/src/test/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPointTests.java
  23. 8
      spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJExpressionPointcutTests.java
  24. 16
      spring-aop/src/test/java/org/springframework/aop/aspectj/TypePatternClassFilterTests.java
  25. 28
      spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java
  26. 6
      spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/ArgumentBindingTests.java
  27. 4
      spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJPointcutAdvisorTests.java
  28. 8
      spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java
  29. 7
      spring-aop/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJNamespaceHandlerTests.java
  30. 11
      spring-aop/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJPrecedenceComparatorTests.java
  31. 2
      spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests-context.xml
  32. 11
      spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java
  33. 2
      spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests-pointcutDuplication.xml
  34. 2
      spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests-pointcutMissing.xml
  35. 4
      spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java
  36. 4
      spring-aop/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java
  37. 8
      spring-aop/src/test/java/org/springframework/aop/framework/AopProxyUtilsTests.java
  38. 6
      spring-aop/src/test/java/org/springframework/aop/framework/IntroductionBenchmarkTests.java
  39. 4
      spring-aop/src/test/java/org/springframework/aop/framework/MethodInvocationTests.java
  40. 5
      spring-aop/src/test/java/org/springframework/aop/framework/PrototypeTargetTests.java
  41. 29
      spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java
  42. 18
      spring-aop/src/test/java/org/springframework/aop/framework/adapter/ThrowsAdviceInterceptorTests.java
  43. 14
      spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java
  44. 4
      spring-aop/src/test/java/org/springframework/aop/interceptor/CustomizableTraceInterceptorTests.java
  45. 6
      spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeBeanNameAdvisorsTests.java
  46. 12
      spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests-context.xml
  47. 11
      spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java
  48. 4
      spring-aop/src/test/java/org/springframework/aop/interceptor/SimpleTraceInterceptorTests.java
  49. 4
      spring-aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java
  50. 11
      spring-aop/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java
  51. 12
      spring-aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java
  52. 6
      spring-aop/src/test/java/org/springframework/aop/support/ClassFiltersTests.java
  53. 4
      spring-aop/src/test/java/org/springframework/aop/support/ClassUtilsTests.java
  54. 4
      spring-aop/src/test/java/org/springframework/aop/support/ComposablePointcutTests.java
  55. 11
      spring-aop/src/test/java/org/springframework/aop/support/ControlFlowPointcutTests.java
  56. 29
      spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java
  57. 15
      spring-aop/src/test/java/org/springframework/aop/support/MethodMatchersTests.java
  58. 16
      spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java
  59. 4
      spring-aop/src/test/java/org/springframework/aop/support/PointcutsTests.java
  60. 22
      spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests-context.xml
  61. 16
      spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java
  62. 2
      spring-aop/src/test/java/org/springframework/aop/target/CommonsPoolTargetSourceProxyTests-context.xml
  63. 7
      spring-aop/src/test/java/org/springframework/aop/target/CommonsPoolTargetSourceProxyTests.java
  64. 11
      spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests-context.xml
  65. 14
      spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java
  66. 2
      spring-aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests-customTarget.xml
  67. 2
      spring-aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests-singleton.xml
  68. 7
      spring-aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java
  69. 12
      spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java
  70. 16
      spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests-context.xml
  71. 7
      spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java
  72. 33
      spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests-context.xml
  73. 9
      spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java
  74. 4
      spring-aop/src/test/java/org/springframework/tests/aop/advice/CountingAfterReturningAdvice.java
  75. 2
      spring-aop/src/test/java/org/springframework/tests/aop/advice/CountingBeforeAdvice.java
  76. 2
      spring-aop/src/test/java/org/springframework/tests/aop/advice/MethodCounter.java
  77. 4
      spring-aop/src/test/java/org/springframework/tests/aop/advice/MyThrowsHandler.java
  78. 4
      spring-aop/src/test/java/org/springframework/tests/aop/advice/TimestampIntroductionAdvisor.java
  79. 2
      spring-aop/src/test/java/org/springframework/tests/aop/interceptor/NopInterceptor.java
  80. 2
      spring-aop/src/test/java/org/springframework/tests/aop/interceptor/SerializableNopInterceptor.java
  81. 7
      spring-aop/src/test/java/org/springframework/tests/aop/interceptor/TimestampIntroductionInterceptor.java
  82. 12
      spring-aop/src/test/java/org/springframework/tests/sample/beans/Person.java
  83. 2
      spring-aop/src/test/java/org/springframework/tests/sample/beans/SerializablePerson.java
  84. 2
      spring-aop/src/test/java/org/springframework/tests/sample/beans/subpkg/DeepBean.java
  85. 2
      spring-aop/src/test/java/test/annotation/EmptySpringAnnotation.java
  86. 2
      spring-aop/src/test/java/test/aop/Lockable.java
  87. 70
      spring-aop/src/test/java/test/aop/MethodCounter.java
  88. 58
      spring-aop/src/test/java/test/aop/NopInterceptor.java
  89. 2
      spring-aop/src/test/java/test/aop/PerTargetAspect.java
  90. 50
      spring-aop/src/test/java/test/aop/SerializableNopInterceptor.java
  91. 2
      spring-aop/src/test/java/test/aop/TwoAdviceAspect.java
  92. 36
      spring-aop/src/test/java/test/beans/Colour.java
  93. 90
      spring-aop/src/test/java/test/beans/DerivedTestBean.java
  94. 23
      spring-aop/src/test/java/test/beans/INestedTestBean.java
  95. 24
      spring-aop/src/test/java/test/beans/IOther.java
  96. 69
      spring-aop/src/test/java/test/beans/ITestBean.java
  97. 61
      spring-aop/src/test/java/test/beans/NestedTestBean.java
  98. 431
      spring-aop/src/test/java/test/beans/TestBean.java
  99. 97
      spring-aop/src/test/java/test/parsing/CollectingReaderEventListener.java
  100. 100
      spring-aop/src/test/java/test/util/SerializationTestUtils.java
  101. Some files were not shown because too many files have changed in this diff Show More

7
.gitignore vendored

@ -13,8 +13,6 @@ jmx.log
derby.log derby.log
spring-test/test-output/ spring-test/test-output/
.gradle .gradle
.classpath
.project
argfile* argfile*
pom.xml pom.xml
@ -22,6 +20,11 @@ pom.xml
buildSrc/build buildSrc/build
/spring-*/build /spring-*/build
# Eclipse artifacts, including WTP generated manifests
.classpath
.project
spring-*/src/main/java/META-INF/MANIFEST.MF
# IDEA artifacts and output dirs # IDEA artifacts and output dirs
*.iml *.iml
*.ipr *.ipr

8
CONTRIBUTING.md

@ -87,7 +87,7 @@ present in the framework.
```java ```java
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -108,16 +108,16 @@ package ...;
## Update Apache license header to modified files as necessary ## Update Apache license header to modified files as necessary
Always check the date range in the license header. For example, if you've Always check the date range in the license header. For example, if you've
modified a file in 2012 whose header still reads modified a file in 2013 whose header still reads
```java ```java
* Copyright 2002-2011 the original author or authors. * Copyright 2002-2011 the original author or authors.
``` ```
then be sure to update it to 2012 appropriately then be sure to update it to 2013 appropriately
```java ```java
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
``` ```
## Use @since tags for newly-added public API types and methods ## Use @since tags for newly-added public API types and methods

81
build.gradle

@ -3,8 +3,8 @@ buildscript {
maven { url "http://repo.springsource.org/plugins-release" } maven { url "http://repo.springsource.org/plugins-release" }
} }
dependencies { dependencies {
classpath("org.springframework.build.gradle:propdeps-plugin:0.0.1") classpath("org.springframework.build.gradle:propdeps-plugin:0.0.3")
classpath("org.springframework.build.gradle:docbook-reference-plugin:0.2.4") classpath("org.springframework.build.gradle:docbook-reference-plugin:0.2.6")
} }
} }
@ -12,7 +12,7 @@ configure(allprojects) { project ->
group = "org.springframework" group = "org.springframework"
version = qualifyVersionIfNecessary(version) version = qualifyVersionIfNecessary(version)
ext.aspectjVersion = "1.7.1" ext.aspectjVersion = "1.7.2"
ext.easymockVersion = "2.5.2" ext.easymockVersion = "2.5.2"
ext.hsqldbVersion = "1.8.0.10" ext.hsqldbVersion = "1.8.0.10"
ext.junitVersion = "4.11" ext.junitVersion = "4.11"
@ -21,8 +21,6 @@ configure(allprojects) { project ->
apply plugin: "propdeps" apply plugin: "propdeps"
apply plugin: "java" apply plugin: "java"
apply plugin: "propdeps-eclipse"
apply plugin: "propdeps-idea"
apply plugin: "test-source-set-dependencies" apply plugin: "test-source-set-dependencies"
apply from: "${gradleScriptDir}/ide.gradle" apply from: "${gradleScriptDir}/ide.gradle"
@ -60,7 +58,7 @@ configure(allprojects) { project ->
test { test {
systemProperty("java.awt.headless", "true") systemProperty("java.awt.headless", "true")
systemProperty("testGroups", properties.get("testGroups")) systemProperty("testGroups", project.properties.get("testGroups"))
} }
repositories { repositories {
@ -71,7 +69,7 @@ configure(allprojects) { project ->
testCompile("junit:junit:${junitVersion}") testCompile("junit:junit:${junitVersion}")
testCompile("org.hamcrest:hamcrest-all:1.3") testCompile("org.hamcrest:hamcrest-all:1.3")
testCompile("org.mockito:mockito-core:1.9.5") testCompile("org.mockito:mockito-core:1.9.5")
if (project.name in ["spring", "spring-jms", "spring-orm", if (project.name in ["spring",
"spring-orm-hibernate4", "spring-oxm", "spring-struts", "spring-orm-hibernate4", "spring-oxm", "spring-struts",
"spring-test", "spring-test-mvc", "spring-tx", "spring-web", "spring-test", "spring-test-mvc", "spring-tx", "spring-web",
"spring-webmvc", "spring-webmvc-portlet", "spring-webmvc-tiles3"]) { "spring-webmvc", "spring-webmvc-portlet", "spring-webmvc-tiles3"]) {
@ -235,7 +233,9 @@ project("spring-core") {
optional("net.sf.jopt-simple:jopt-simple:3.0") optional("net.sf.jopt-simple:jopt-simple:3.0")
optional("log4j:log4j:1.2.17") optional("log4j:log4j:1.2.17")
testCompile("xmlunit:xmlunit:1.3") testCompile("xmlunit:xmlunit:1.3")
testCompile("org.codehaus.woodstox:wstx-asl:3.2.7") testCompile("org.codehaus.woodstox:wstx-asl:3.2.7") {
exclude group: "stax", module: "stax-api"
}
} }
jar { jar {
@ -526,8 +526,8 @@ project("spring-orm-hibernate4") {
description = "Spring Object/Relational Mapping - Hibernate 4 support" description = "Spring Object/Relational Mapping - Hibernate 4 support"
merge.into = project(":spring-orm") merge.into = project(":spring-orm")
dependencies { dependencies {
compile(project(":spring-tx")) provided(project(":spring-tx"))
compile(project(":spring-jdbc")) provided(project(":spring-jdbc"))
optional("org.hibernate:hibernate-core:4.1.0.Final") optional("org.hibernate:hibernate-core:4.1.0.Final")
optional("org.hibernate:hibernate-entitymanager:4.1.0.Final") optional("org.hibernate:hibernate-entitymanager:4.1.0.Final")
optional(project(":spring-web")) optional(project(":spring-web"))
@ -587,7 +587,6 @@ project("spring-webmvc") {
testCompile("commons-io:commons-io:1.3") testCompile("commons-io:commons-io:1.3")
testCompile("org.hibernate:hibernate-validator:4.3.0.Final") testCompile("org.hibernate:hibernate-validator:4.3.0.Final")
testCompile("org.apache.httpcomponents:httpclient:4.2") testCompile("org.apache.httpcomponents:httpclient:4.2")
testCompile(project(":spring-web").sourceSets.test.output)
} }
// pick up DispatcherServlet.properties in src/main // pick up DispatcherServlet.properties in src/main
@ -598,7 +597,8 @@ project("spring-webmvc-tiles3") {
description = "Spring Framework Tiles3 Integration" description = "Spring Framework Tiles3 Integration"
merge.into = project(":spring-webmvc") merge.into = project(":spring-webmvc")
dependencies { dependencies {
compile(project(":spring-context")) provided(project(":spring-context"))
provided(project(":spring-web"))
provided("javax.el:el-api:1.0") provided("javax.el:el-api:1.0")
provided("javax.servlet:jstl:1.2") provided("javax.servlet:jstl:1.2")
provided("javax.servlet.jsp:jsp-api:2.1") provided("javax.servlet.jsp:jsp-api:2.1")
@ -613,11 +613,13 @@ project("spring-webmvc-tiles3") {
optional("org.apache.tiles:tiles-jsp:3.0.1") { optional("org.apache.tiles:tiles-jsp:3.0.1") {
exclude group: "org.slf4j", module: "jcl-over-slf4j" exclude group: "org.slf4j", module: "jcl-over-slf4j"
} }
optional("org.apache.tiles:tiles-extras:3.0.1") {
exclude group: "org.slf4j", module: "jcl-over-slf4j"
}
optional("org.apache.tiles:tiles-el:3.0.1") { optional("org.apache.tiles:tiles-el:3.0.1") {
exclude group: "org.slf4j", module: "jcl-over-slf4j" exclude group: "org.slf4j", module: "jcl-over-slf4j"
} }
provided("javax.servlet:javax.servlet-api:3.0.1") provided("javax.servlet:javax.servlet-api:3.0.1")
compile(project(":spring-web").sourceSets*.output) // mock request & response
testCompile("org.slf4j:slf4j-jcl:${slf4jVersion}") testCompile("org.slf4j:slf4j-jcl:${slf4jVersion}")
} }
} }
@ -641,10 +643,22 @@ project("spring-webmvc-portlet") {
project("spring-test") { project("spring-test") {
description = "Spring TestContext Framework" description = "Spring TestContext Framework"
task testNG(type: Test) {
useTestNG()
// "TestCase" classes are run by other test classes, not the build.
exclude "**/*TestCase.class"
// Generate TestNG reports alongside JUnit reports.
testReport true
}
test { test {
dependsOn testNG
useJUnit() useJUnit()
useTestNG() // "TestCase" classes are run by other test classes, not the build.
exclude(["**/*TestCase.class", "**/*TestSuite.class"])
} }
dependencies { dependencies {
compile(project(":spring-core")) compile(project(":spring-core"))
optional(project(":spring-beans")) optional(project(":spring-beans"))
@ -676,7 +690,7 @@ project("spring-test-mvc") {
merge.into = project(":spring-test") merge.into = project(":spring-test")
dependencies { dependencies {
optional(project(":spring-context")) optional(project(":spring-context"))
compile(project(":spring-webmvc")) provided(project(":spring-webmvc"))
provided("javax.servlet:javax.servlet-api:3.0.1") provided("javax.servlet:javax.servlet-api:3.0.1")
optional("org.hamcrest:hamcrest-core:1.3") optional("org.hamcrest:hamcrest-core:1.3")
optional("com.jayway.jsonpath:json-path:0.8.1") optional("com.jayway.jsonpath:json-path:0.8.1")
@ -753,6 +767,7 @@ configure(rootProject) {
apply plugin: "docbook-reference" apply plugin: "docbook-reference"
apply plugin: "groovy" apply plugin: "groovy"
apply plugin: "detect-split-packages"
apply from: "${gradleScriptDir}/jdiff.gradle" apply from: "${gradleScriptDir}/jdiff.gradle"
reference { reference {
@ -760,12 +775,15 @@ configure(rootProject) {
pdfFilename = "spring-framework-reference.pdf" pdfFilename = "spring-framework-reference.pdf"
} }
// don"t publish the default jar for the root project detectSplitPackages {
projectsToScan -= project(":spring-instrument-tomcat")
}
// don't publish the default jar for the root project
configurations.archives.artifacts.clear() configurations.archives.artifacts.clear()
dependencies { // for integration tests dependencies { // for integration tests
testCompile(project(":spring-core")) testCompile(project(":spring-core"))
testCompile(project(":spring-core").sourceSets.test.output)
testCompile(project(":spring-beans")) testCompile(project(":spring-beans"))
testCompile(project(":spring-aop")) testCompile(project(":spring-aop"))
testCompile(project(":spring-expression")) testCompile(project(":spring-expression"))
@ -790,10 +808,16 @@ configure(rootProject) {
description = "Generates aggregated Javadoc API documentation." description = "Generates aggregated Javadoc API documentation."
title = "${rootProject.description} ${version} API" title = "${rootProject.description} ${version} API"
dependsOn {
subprojects.collect {
it.tasks.getByName("jar")
}
}
options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
options.author = true options.author = true
options.header = rootProject.description options.header = rootProject.description
options.overview = "src/api/overview.html" options.overview = "src/api/overview.html"
options.stylesheetFile = file("src/api/stylesheet.css")
options.splitIndex = true options.splitIndex = true
options.links(project.ext.javadocLinks) options.links(project.ext.javadocLinks)
@ -801,18 +825,20 @@ configure(rootProject) {
project.sourceSets.main.allJava project.sourceSets.main.allJava
} }
classpath = files(
// ensure servlet 3.x and Hibernate 4.x have precedence on the Javadoc
// classpath over their respective 2.5 and 3.x variants
project(":spring-webmvc").sourceSets.main.compileClasspath.files.find { it =~ "servlet-api" },
rootProject.sourceSets.test.compileClasspath.files.find { it =~ "hibernate-core" },
// ensure the javadoc process can resolve types compiled from .aj sources
project(":spring-aspects").sourceSets.main.output
)
classpath += files(subprojects.collect { it.sourceSets.main.compileClasspath })
maxMemory = "1024m" maxMemory = "1024m"
destinationDir = new File(buildDir, "api") destinationDir = new File(buildDir, "api")
doFirst {
classpath = files(
// ensure servlet 3.x and Hibernate 4.x have precedence on the Javadoc
// classpath over their respective 2.5 and 3.x variants
project(":spring-webmvc").sourceSets.main.compileClasspath.files.find { it =~ "servlet-api" },
rootProject.sourceSets.test.compileClasspath.files.find { it =~ "hibernate-core" },
// ensure the javadoc process can resolve types compiled from .aj sources
project(":spring-aspects").sourceSets.main.output
)
classpath += files(subprojects.collect { it.sourceSets.main.compileClasspath })
}
} }
task docsZip(type: Zip) { task docsZip(type: Zip) {
@ -954,6 +980,7 @@ configure(rootProject) {
"set GRADLE_OPTS=$gradleBatOpts %GRADLE_OPTS%\nset DEFAULT_JVM_OPTS=") "set GRADLE_OPTS=$gradleBatOpts %GRADLE_OPTS%\nset DEFAULT_JVM_OPTS=")
} }
} }
} }
/* /*

158
buildSrc/src/main/groovy/org/springframework/build/gradle/DetectSplitPackagesPlugin.groovy

@ -0,0 +1,158 @@
/*
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://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.gradle
import org.gradle.api.DefaultTask
import org.gradle.api.GradleException
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.TaskAction
/**
* Gradle plugin that detects identically named, non-empty packages split across multiple
* subprojects, e.g. "org.springframework.context.annotation" existing in both spring-core
* and spring-aspects. Adds a 'detectSplitPackages' task to the current project's task
* collection. If the project already contains a 'check' task (i.e. is a typical Gradle
* project with the "java" plugin applied), the 'check' task will be updated to depend on
* the execution of 'detectSplitPackages'.
*
* By default, all subprojects will be scanned. Use the 'projectsToScan' task property to
* modify this value. Example usage:
*
* apply plugin: 'detect-split-packages // typically applied to root project
*
* detectSplitPackages {
* packagesToScan -= project(":spring-xyz") // scan every project but spring-xyz
* }
*
* @author Rob Winch
* @author Glyn Normington
* @author Chris Beams
*/
public class DetectSplitPackagesPlugin implements Plugin<Project> {
public void apply(Project project) {
def tasks = project.tasks
Task detectSplitPackages = tasks.add("detectSplitPackages", DetectSplitPackagesTask.class)
if (tasks.asMap.containsKey("check")) {
tasks.getByName("check").dependsOn detectSplitPackages
}
}
}
public class DetectSplitPackagesTask extends DefaultTask {
private static final String JAVA_FILE_SUFFIX = ".java"
private static final String PACKAGE_SEPARATOR = "."
private static final String HIDDEN_DIRECTORY_PREFIX = "."
@Input
Set<Project> projectsToScan = project.subprojects
public DetectSplitPackagesTask() {
this.group = "Verification"
this.description = "Detects packages split across two or more subprojects."
}
@TaskAction
public void detectSplitPackages() {
def splitPackages = doDetectSplitPackages()
if (!splitPackages.isEmpty()) {
def message = "The following split package(s) have been detected:\n"
splitPackages.each { pkg, mod ->
message += " - ${pkg} (split across ${mod[0].name} and ${mod[1].name})\n"
}
throw new GradleException(message)
}
}
private Map<String, List<Project>> doDetectSplitPackages() {
def splitPackages = [:]
def mergedProjects = findMergedProjects()
def packagesByProject = mapPackagesByProject()
def projects = packagesByProject.keySet().toArray()
def nProjects = projects.length
for (int i = 0; i < nProjects - 1; i++) {
for (int j = i + 1; j < nProjects - 1; j++) {
def prj_i = projects[i]
def prj_j = projects[j]
def pkgs_i = new HashSet(packagesByProject.get(prj_i))
def pkgs_j = packagesByProject.get(prj_j)
pkgs_i.retainAll(pkgs_j)
if (!pkgs_i.isEmpty()
&& mergedProjects.get(prj_i) != prj_j
&& mergedProjects.get(prj_j) != prj_i) {
pkgs_i.each { pkg ->
def readablePkg = pkg.substring(1).replaceAll(File.separator, PACKAGE_SEPARATOR)
splitPackages[readablePkg] = [prj_i, prj_j]
}
}
}
}
return splitPackages;
}
private Map<Project, Set<String>> mapPackagesByProject() {
def packagesByProject = [:]
this.projectsToScan.each { Project p ->
def packages = new HashSet<String>()
p.sourceSets.main.java.srcDirs.each { File dir ->
findPackages(packages, dir, "")
}
if (!packages.isEmpty()) {
packagesByProject.put(p, packages)
}
}
return packagesByProject;
}
private Map<Project, Project> findMergedProjects() {
def mergedProjects = [:]
this.projectsToScan.findAll { p ->
p.plugins.findPlugin(MergePlugin)
}.findAll { p ->
p.merge.into
}.each { p ->
mergedProjects.put(p, p.merge.into)
}
return mergedProjects
}
private static void findPackages(Set<String> packages, File dir, String packagePath) {
def scanDir = new File(dir, packagePath)
def File[] javaFiles = scanDir.listFiles({ file ->
!file.isDirectory() && file.name.endsWith(JAVA_FILE_SUFFIX)
} as FileFilter)
if (javaFiles != null && javaFiles.length != 0) {
packages.add(packagePath)
}
scanDir.listFiles({ File file ->
file.isDirectory() && !file.name.startsWith(HIDDEN_DIRECTORY_PREFIX)
} as FileFilter).each { File subDir ->
findPackages(packages, dir, packagePath + File.separator + subDir.name)
}
}
}

12
buildSrc/src/main/groovy/org/springframework/build/gradle/MergePlugin.groovy

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -110,7 +110,7 @@ class MergePlugin implements Plugin<Project> {
// update 'into' project artifacts to contain the source artifact contents // update 'into' project artifacts to contain the source artifact contents
project.merge.into.sourcesJar.from(project.sourcesJar.source) project.merge.into.sourcesJar.from(project.sourcesJar.source)
project.merge.into.jar.from(project.jar.source) project.merge.into.jar.from(project.sourceSets.main.output)
project.merge.into.javadoc { project.merge.into.javadoc {
source += project.javadoc.source source += project.javadoc.source
classpath += project.javadoc.classpath classpath += project.javadoc.classpath
@ -128,7 +128,13 @@ class MergePlugin implements Plugin<Project> {
(ExcludeRule.GROUP_KEY) : it.group, (ExcludeRule.GROUP_KEY) : it.group,
(ExcludeRule.MODULE_KEY) : it.module]) (ExcludeRule.MODULE_KEY) : it.module])
} }
intoConfiguration.dependencies.addAll(configuration.dependencies) configuration.dependencies.each {
def intoCompile = project.merge.into.configurations.getByName("compile")
// Protect against changing a compile scope dependency (SPR-10218)
if(!intoCompile.dependencies.contains(it)) {
intoConfiguration.dependencies.add(it)
}
}
project.merge.into.install.repositories.mavenInstaller.pom.scopeMappings.addMapping( project.merge.into.install.repositories.mavenInstaller.pom.scopeMappings.addMapping(
mapping.priority + 100, intoConfiguration, mapping.scope) mapping.priority + 100, intoConfiguration, mapping.scope)
} }

2
buildSrc/src/main/groovy/org/springframework/build/gradle/TestSourceSetDependenciesPlugin.groovy

@ -43,7 +43,7 @@ class TestSourceSetDependenciesPlugin implements Plugin<Project> {
private void collectProjectDependencies(Set<ProjectDependency> projectDependencies, private void collectProjectDependencies(Set<ProjectDependency> projectDependencies,
Project project) { Project project) {
for(def configurationName in ["compile", "optional", "provided"]) { for(def configurationName in ["compile", "optional", "provided", "testCompile"]) {
Configuration configuration = project.getConfigurations().findByName(configurationName) Configuration configuration = project.getConfigurations().findByName(configurationName)
if(configuration) { if(configuration) {
configuration.dependencies.findAll { it instanceof ProjectDependency }.each { configuration.dependencies.findAll { it instanceof ProjectDependency }.each {

1
buildSrc/src/main/resources/META-INF/gradle-plugins/detect-split-packages.properties

@ -0,0 +1 @@
implementation-class=org.springframework.build.gradle.DetectSplitPackagesPlugin

80
gradle/ide.gradle

@ -1,7 +1,12 @@
import org.gradle.plugins.ide.eclipse.model.ProjectDependency import org.gradle.plugins.ide.eclipse.model.ProjectDependency
import org.gradle.plugins.ide.eclipse.model.SourceFolder
apply plugin: "propdeps-eclipse"
apply plugin: "propdeps-idea"
// Replace classpath entries with project dependencies (GRADLE-1116)
eclipse.classpath.file.whenMerged { classpath -> eclipse.classpath.file.whenMerged { classpath ->
// GRADLE-1116
def regexp = /.*?\/([^\/]+)\/build\/[^\/]+\/(?:main|test)/ // only match those that end in main or test (avoids removing necessary entries like build/classes/jaxb) def regexp = /.*?\/([^\/]+)\/build\/[^\/]+\/(?:main|test)/ // only match those that end in main or test (avoids removing necessary entries like build/classes/jaxb)
def projectOutputDependencies = classpath.entries.findAll { entry -> entry.path =~ regexp } def projectOutputDependencies = classpath.entries.findAll { entry -> entry.path =~ regexp }
projectOutputDependencies.each { entry -> projectOutputDependencies.each { entry ->
@ -19,3 +24,76 @@ eclipse.classpath.file.whenMerged { classpath ->
} }
classpath.entries.removeAll { entry -> (entry.path =~ /(?!.*?repack.*\.jar).*?\/([^\/]+)\/build\/libs\/[^\/]+\.jar/) } classpath.entries.removeAll { entry -> (entry.path =~ /(?!.*?repack.*\.jar).*?\/([^\/]+)\/build\/libs\/[^\/]+\.jar/) }
} }
// Use separate main/test outputs (prevents WTP from packaging test classes)
eclipse.classpath.defaultOutputDir = file(project.name+"/bin/eclipse")
eclipse.classpath.file.beforeMerged { classpath ->
classpath.entries.findAll{ it instanceof SourceFolder }.each {
if(it.output.startsWith("bin/")) {
it.output = null
}
}
}
eclipse.classpath.file.whenMerged { classpath ->
classpath.entries.findAll{ it instanceof SourceFolder }.each {
it.output = "bin/" + it.path.split("/")[1]
}
}
// Allow projects to be used as WPT modules
eclipse.project.natures "org.eclipse.wst.common.project.facet.core.nature"
// Include project specific settings
task eclipseSettings(type: Copy) {
from rootProject.files(
"src/eclipse/org.eclipse.jdt.ui.prefs",
"src/eclipse/org.eclipse.wst.common.project.facet.core.xml")
into project.file('.settings/')
outputs.upToDateWhen { false }
}
task eclipseWstComponent(type: Copy) {
from rootProject.files(
"src/eclipse/org.eclipse.wst.common.component")
into project.file('.settings/')
expand(deployname: project.name)
outputs.upToDateWhen { false }
}
task eclipseJdtPrepare(type: Copy) {
from rootProject.file("src/eclipse/org.eclipse.jdt.core.prefs")
into project.file(".settings/")
outputs.upToDateWhen { false }
}
task cleanEclipseJdtUi(type: Delete) {
delete project.file(".settings/org.eclipse.jdt.ui.prefs")
delete project.file("org.eclipse.jdt.core.prefs")
delete project.file(".settings/org.eclipse.wst.common.component")
delete project.file(".settings/org.eclipse.wst.common.project.facet.core.xml")
}
tasks["eclipseJdt"].dependsOn(eclipseJdtPrepare)
tasks["cleanEclipse"].dependsOn(cleanEclipseJdtUi)
tasks["eclipse"].dependsOn(eclipseSettings, eclipseWstComponent)
// Filter 'build' folder
eclipse.project.file.withXml {
def node = it.asNode()
def filteredResources = node.get("filteredResources")
if(filteredResources) {
node.remove(filteredResources)
}
def filterNode = node.appendNode("filteredResources").appendNode("filter")
filterNode.appendNode("id", "1359048889071")
filterNode.appendNode("name", "")
filterNode.appendNode("type", "30")
def matcherNode = filterNode.appendNode("matcher")
matcherNode.appendNode("id", "org.eclipse.ui.ide.multiFilter")
matcherNode.appendNode("arguments", "1.0-projectRelativePath-matches-false-false-build")
}

5
gradle/publish-maven.gradle

@ -13,6 +13,11 @@ def customizePom(pom, gradleProject) {
dep.scope == "test" dep.scope == "test"
} }
// sort to make pom dependencies order consistent to ease comparison of older poms
generatedPom.dependencies = generatedPom.dependencies.sort { dep ->
"$dep.scope:$dep.groupId:$dep.artifactId"
}
// add all items necessary for maven central publication // add all items necessary for maven central publication
generatedPom.project { generatedPom.project {
name = gradleProject.description name = gradleProject.description

4
spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java

@ -282,8 +282,8 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
return false; return false;
} }
else { else {
// the maybe case // the maybe case
return (beanHasIntroductions || matchesIgnoringSubtypes(shadowMatch) || matchesTarget(shadowMatch, targetClass)); return (beanHasIntroductions || matchesIgnoringSubtypes(shadowMatch) || matchesTarget(shadowMatch, targetClass));
} }
} }

4
spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJProxyUtils.java

@ -64,8 +64,8 @@ public abstract class AspectJProxyUtils {
*/ */
private static boolean isAspectJAdvice(Advisor advisor) { private static boolean isAspectJAdvice(Advisor advisor) {
return (advisor instanceof InstantiationModelAwarePointcutAdvisor || return (advisor instanceof InstantiationModelAwarePointcutAdvisor ||
advisor.getAdvice() instanceof AbstractAspectJAdvice || advisor.getAdvice() instanceof AbstractAspectJAdvice ||
(advisor instanceof PointcutAdvisor && (advisor instanceof PointcutAdvisor &&
((PointcutAdvisor) advisor).getPointcut() instanceof AspectJExpressionPointcut)); ((PointcutAdvisor) advisor).getPointcut() instanceof AspectJExpressionPointcut));
} }

4
spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/InstantiationModelAwarePointcutAdvisorImpl.java

@ -63,8 +63,8 @@ class InstantiationModelAwarePointcutAdvisorImpl
private Boolean isAfterAdvice; private Boolean isAfterAdvice;
public InstantiationModelAwarePointcutAdvisorImpl(AspectJAdvisorFactory af, AspectJExpressionPointcut ajexp, public InstantiationModelAwarePointcutAdvisorImpl(AspectJAdvisorFactory af, AspectJExpressionPointcut ajexp,
MetadataAwareAspectInstanceFactory aif, Method method, int declarationOrderInAspect, String aspectName) { MetadataAwareAspectInstanceFactory aif, Method method, int declarationOrderInAspect, String aspectName) {
this.declaredPointcut = ajexp; this.declaredPointcut = ajexp;
this.method = method; this.method = method;

27
spring-aop/src/main/java/org/springframework/aop/aspectj/autoproxy/AspectJAwareAdvisorAutoProxyCreator.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,8 +16,8 @@
package org.springframework.aop.aspectj.autoproxy; package org.springframework.aop.aspectj.autoproxy;
import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.aopalliance.aop.Advice; import org.aopalliance.aop.Advice;
@ -67,29 +67,24 @@ public class AspectJAwareAdvisorAutoProxyCreator extends AbstractAdvisorAutoProx
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
protected List<Advisor> sortAdvisors(List<Advisor> advisors) { protected List<Advisor> sortAdvisors(List<Advisor> advisors) {
// build list for sorting
List<PartiallyComparableAdvisorHolder> partiallyComparableAdvisors = List<PartiallyComparableAdvisorHolder> partiallyComparableAdvisors =
new LinkedList<PartiallyComparableAdvisorHolder>(); new ArrayList<PartiallyComparableAdvisorHolder>(advisors.size());
for (Advisor element : advisors) { for (Advisor element : advisors) {
partiallyComparableAdvisors.add( partiallyComparableAdvisors.add(
new PartiallyComparableAdvisorHolder(element, DEFAULT_PRECEDENCE_COMPARATOR)); new PartiallyComparableAdvisorHolder(element, DEFAULT_PRECEDENCE_COMPARATOR));
} }
// sort it
List<PartiallyComparableAdvisorHolder> sorted = List<PartiallyComparableAdvisorHolder> sorted =
PartialOrder.sort(partiallyComparableAdvisors); PartialOrder.sort(partiallyComparableAdvisors);
if (sorted == null) { if (sorted != null) {
// TODO: work harder to give a better error message here. List<Advisor> result = new ArrayList<Advisor>(advisors.size());
throw new IllegalArgumentException("Advice precedence circularity error"); for (PartiallyComparableAdvisorHolder pcAdvisor : sorted) {
result.add(pcAdvisor.getAdvisor());
}
return result;
} }
else {
// extract results again return super.sortAdvisors(advisors);
List<Advisor> result = new LinkedList<Advisor>();
for (PartiallyComparableAdvisorHolder pcAdvisor : sorted) {
result.add(pcAdvisor.getAdvisor());
} }
return result;
} }
/** /**

21
spring-aop/src/main/java/org/springframework/aop/aspectj/autoproxy/AspectJPrecedenceComparator.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -53,7 +53,6 @@ class AspectJPrecedenceComparator implements Comparator {
private static final int HIGHER_PRECEDENCE = -1; private static final int HIGHER_PRECEDENCE = -1;
private static final int SAME_PRECEDENCE = 0; private static final int SAME_PRECEDENCE = 0;
private static final int LOWER_PRECEDENCE = 1; private static final int LOWER_PRECEDENCE = 1;
private static final int NOT_COMPARABLE = 0;
private final Comparator<? super Advisor> advisorComparator; private final Comparator<? super Advisor> advisorComparator;
@ -85,21 +84,11 @@ class AspectJPrecedenceComparator implements Comparator {
Advisor advisor1 = (Advisor) o1; Advisor advisor1 = (Advisor) o1;
Advisor advisor2 = (Advisor) o2; Advisor advisor2 = (Advisor) o2;
int advisorPrecedence = this.advisorComparator.compare(advisor1, advisor2);
boolean oneOrOtherIsAfterAdvice = if (advisorPrecedence == SAME_PRECEDENCE && declaredInSameAspect(advisor1, advisor2)) {
(AspectJAopUtils.isAfterAdvice(advisor1) || AspectJAopUtils.isAfterAdvice(advisor2)); advisorPrecedence = comparePrecedenceWithinAspect(advisor1, advisor2);
boolean oneOrOtherIsBeforeAdvice =
(AspectJAopUtils.isBeforeAdvice(advisor1) || AspectJAopUtils.isBeforeAdvice(advisor2));
if (oneOrOtherIsAfterAdvice && oneOrOtherIsBeforeAdvice) {
return NOT_COMPARABLE;
}
else {
int advisorPrecedence = this.advisorComparator.compare(advisor1, advisor2);
if (advisorPrecedence == SAME_PRECEDENCE && declaredInSameAspect(advisor1, advisor2)) {
advisorPrecedence = comparePrecedenceWithinAspect(advisor1, advisor2);
}
return advisorPrecedence;
} }
return advisorPrecedence;
} }
private int comparePrecedenceWithinAspect(Advisor advisor1, Advisor advisor2) { private int comparePrecedenceWithinAspect(Advisor advisor1, Advisor advisor2) {

14
spring-aop/src/main/java/org/springframework/aop/framework/AbstractAdvisingBeanPostProcessor.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -47,7 +47,7 @@ public abstract class AbstractAdvisingBeanPostProcessor extends ProxyConfig
*/ */
private int order = Ordered.LOWEST_PRECEDENCE; private int order = Ordered.LOWEST_PRECEDENCE;
private final Map<String, Boolean> eligibleBeans = new ConcurrentHashMap<String, Boolean>(64); private final Map<Class, Boolean> eligibleBeans = new ConcurrentHashMap<Class, Boolean>(64);
public void setBeanClassLoader(ClassLoader beanClassLoader) { public void setBeanClassLoader(ClassLoader beanClassLoader) {
@ -94,19 +94,21 @@ public abstract class AbstractAdvisingBeanPostProcessor extends ProxyConfig
/** /**
* Check whether the given bean is eligible for advising with this * Check whether the given bean is eligible for advising with this
* post-processor's {@link Advisor}. * post-processor's {@link Advisor}.
* <p>Implements caching of {@code canApply} results per bean name. * <p>Implements caching of {@code canApply} results per bean target class.
* Can be overridden e.g. to specifically exclude certain beans by name.
* @param bean the bean instance * @param bean the bean instance
* @param beanName the name of the bean * @param beanName the name of the bean
* @see AopUtils#getTargetClass(Object)
* @see AopUtils#canApply(Advisor, Class) * @see AopUtils#canApply(Advisor, Class)
*/ */
protected boolean isEligible(Object bean, String beanName) { protected boolean isEligible(Object bean, String beanName) {
Boolean eligible = this.eligibleBeans.get(beanName); Class<?> targetClass = AopUtils.getTargetClass(bean);
Boolean eligible = this.eligibleBeans.get(targetClass);
if (eligible != null) { if (eligible != null) {
return eligible; return eligible;
} }
Class<?> targetClass = AopUtils.getTargetClass(bean);
eligible = AopUtils.canApply(this.advisor, targetClass); eligible = AopUtils.canApply(this.advisor, targetClass);
this.eligibleBeans.put(beanName, eligible); this.eligibleBeans.put(targetClass, eligible);
return eligible; return eligible;
} }

4
spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java

@ -152,11 +152,11 @@ public abstract class AbstractAutoProxyCreator extends ProxyConfig
* @param order ordering value * @param order ordering value
*/ */
public final void setOrder(int order) { public final void setOrder(int order) {
this.order = order; this.order = order;
} }
public final int getOrder() { public final int getOrder() {
return this.order; return this.order;
} }
/** /**

33
spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionAspectSupport.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,8 +17,8 @@
package org.springframework.aop.interceptor; package org.springframework.aop.interceptor;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
@ -45,7 +45,7 @@ import org.springframework.util.StringUtils;
*/ */
public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware { public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware {
private final Map<Method, AsyncTaskExecutor> executors = new HashMap<Method, AsyncTaskExecutor>(); private final Map<Method, AsyncTaskExecutor> executors = new ConcurrentHashMap<Method, AsyncTaskExecutor>(16);
private Executor defaultExecutor; private Executor defaultExecutor;
@ -59,7 +59,7 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware {
* @param defaultExecutor the executor to use when executing asynchronous methods * @param defaultExecutor the executor to use when executing asynchronous methods
*/ */
public AsyncExecutionAspectSupport(Executor defaultExecutor) { public AsyncExecutionAspectSupport(Executor defaultExecutor) {
this.setExecutor(defaultExecutor); this.defaultExecutor = defaultExecutor;
} }
@ -90,24 +90,25 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware {
* @return the executor to use (never {@code null}) * @return the executor to use (never {@code null})
*/ */
protected AsyncTaskExecutor determineAsyncExecutor(Method method) { protected AsyncTaskExecutor determineAsyncExecutor(Method method) {
if (!this.executors.containsKey(method)) { AsyncTaskExecutor executor = this.executors.get(method);
Executor executor = this.defaultExecutor; if (executor == null) {
Executor executorToUse = this.defaultExecutor;
String qualifier = getExecutorQualifier(method); String qualifier = getExecutorQualifier(method);
if (StringUtils.hasLength(qualifier)) { if (StringUtils.hasLength(qualifier)) {
Assert.notNull(this.beanFactory, Assert.notNull(this.beanFactory, "BeanFactory must be set on " + getClass().getSimpleName() +
"BeanFactory must be set on " + this.getClass().getSimpleName() + " to access qualified executor '" + qualifier + "'");
" to access qualified executor [" + qualifier + "]"); executorToUse = BeanFactoryAnnotationUtils.qualifiedBeanOfType(
executor = BeanFactoryAnnotationUtils.qualifiedBeanOfType(
this.beanFactory, Executor.class, qualifier); this.beanFactory, Executor.class, qualifier);
} }
if (executor instanceof AsyncTaskExecutor) { else if (executorToUse == null) {
this.executors.put(method, (AsyncTaskExecutor) executor); throw new IllegalStateException("No executor qualifier specified and no default executor set on " +
} getClass().getSimpleName() + " either");
else if (executor != null) {
this.executors.put(method, new TaskExecutorAdapter(executor));
} }
executor = (executorToUse instanceof AsyncTaskExecutor ?
(AsyncTaskExecutor) executorToUse : new TaskExecutorAdapter(executorToUse));
this.executors.put(method, executor);
} }
return this.executors.get(method); return executor;
} }
/** /**

20
spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionInterceptor.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,7 +17,6 @@
package org.springframework.aop.interceptor; package org.springframework.aop.interceptor;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.concurrent.Future; import java.util.concurrent.Future;
@ -25,8 +24,11 @@ import java.util.concurrent.Future;
import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation; import org.aopalliance.intercept.MethodInvocation;
import org.springframework.aop.support.AopUtils;
import org.springframework.core.BridgeMethodResolver;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.core.task.AsyncTaskExecutor; import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.util.ClassUtils;
import org.springframework.util.ReflectionUtils; import org.springframework.util.ReflectionUtils;
/** /**
@ -76,7 +78,11 @@ public class AsyncExecutionInterceptor extends AsyncExecutionAspectSupport
* otherwise. * otherwise.
*/ */
public Object invoke(final MethodInvocation invocation) throws Throwable { public Object invoke(final MethodInvocation invocation) throws Throwable {
Future<?> result = this.determineAsyncExecutor(invocation.getMethod()).submit( Class<?> targetClass = (invocation.getThis() != null ? AopUtils.getTargetClass(invocation.getThis()) : null);
Method specificMethod = ClassUtils.getMostSpecificMethod(invocation.getMethod(), targetClass);
specificMethod = BridgeMethodResolver.findBridgedMethod(specificMethod);
Future<?> result = determineAsyncExecutor(specificMethod).submit(
new Callable<Object>() { new Callable<Object>() {
public Object call() throws Exception { public Object call() throws Exception {
try { try {
@ -91,6 +97,7 @@ public class AsyncExecutionInterceptor extends AsyncExecutionAspectSupport
return null; return null;
} }
}); });
if (Future.class.isAssignableFrom(invocation.getMethod().getReturnType())) { if (Future.class.isAssignableFrom(invocation.getMethod().getReturnType())) {
return result; return result;
} }
@ -100,10 +107,9 @@ public class AsyncExecutionInterceptor extends AsyncExecutionAspectSupport
} }
/** /**
* {@inheritDoc} * This implementation is a no-op for compatibility in Spring 3.1.2.
* <p>This implementation is a no-op for compatibility in Spring 3.1.2. Subclasses may * Subclasses may override to provide support for extracting qualifier information,
* override to provide support for extracting qualifier information, e.g. via an * e.g. via an annotation on the given method.
* annotation on the given method.
* @return always {@code null} * @return always {@code null}
* @see #determineAsyncExecutor(Method) * @see #determineAsyncExecutor(Method)
* @since 3.1.2 * @since 3.1.2

2
spring-aop/src/main/java/org/springframework/aop/support/DelegatingIntroductionInterceptor.java

@ -95,7 +95,7 @@ public class DelegatingIntroductionInterceptor extends IntroductionInfoSupport
/** /**
* Subclasses may need to override this if they want to perform custom * Subclasses may need to override this if they want to perform custom
* behaviour in around advice. However, subclasses should invoke this * behaviour in around advice. However, subclasses should invoke this
* method, which handles introduced interfaces and forwarding to the target. * method, which handles introduced interfaces and forwarding to the target.
*/ */

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -33,10 +33,10 @@ import org.springframework.aop.Pointcut;
import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.support.DefaultPointcutAdvisor; import org.springframework.aop.support.DefaultPointcutAdvisor;
import test.beans.IOther; import org.springframework.tests.sample.beans.IOther;
import test.beans.ITestBean; import org.springframework.tests.sample.beans.ITestBean;
import test.beans.TestBean; import org.springframework.tests.sample.beans.TestBean;
import test.beans.subpkg.DeepBean; import org.springframework.tests.sample.beans.subpkg.DeepBean;
/** /**
* @author Rob Harrop * @author Rob Harrop
@ -66,7 +66,7 @@ public final class AspectJExpressionPointcutTests {
@Test @Test
public void testMatchExplicit() { public void testMatchExplicit() {
String expression = "execution(int test.beans.TestBean.getAge())"; String expression = "execution(int org.springframework.tests.sample.beans.TestBean.getAge())";
Pointcut pointcut = getPointcut(expression); Pointcut pointcut = getPointcut(expression);
ClassFilter classFilter = pointcut.getClassFilter(); ClassFilter classFilter = pointcut.getClassFilter();
@ -128,8 +128,8 @@ public final class AspectJExpressionPointcutTests {
* @throws SecurityException * @throws SecurityException
*/ */
private void testThisOrTarget(String which) throws SecurityException, NoSuchMethodException { private void testThisOrTarget(String which) throws SecurityException, NoSuchMethodException {
String matchesTestBean = which + "(test.beans.TestBean)"; String matchesTestBean = which + "(org.springframework.tests.sample.beans.TestBean)";
String matchesIOther = which + "(test.beans.IOther)"; String matchesIOther = which + "(org.springframework.tests.sample.beans.IOther)";
AspectJExpressionPointcut testBeanPc = new AspectJExpressionPointcut(); AspectJExpressionPointcut testBeanPc = new AspectJExpressionPointcut();
testBeanPc.setExpression(matchesTestBean); testBeanPc.setExpression(matchesTestBean);
@ -156,7 +156,7 @@ public final class AspectJExpressionPointcutTests {
} }
private void testWithinPackage(boolean matchSubpackages) throws SecurityException, NoSuchMethodException { private void testWithinPackage(boolean matchSubpackages) throws SecurityException, NoSuchMethodException {
String withinBeansPackage = "within(test.beans."; String withinBeansPackage = "within(org.springframework.tests.sample.beans.";
// Subpackages are matched by ** // Subpackages are matched by **
if (matchSubpackages) { if (matchSubpackages) {
withinBeansPackage += "."; withinBeansPackage += ".";
@ -214,7 +214,7 @@ public final class AspectJExpressionPointcutTests {
@Test @Test
public void testMatchWithArgs() throws Exception { public void testMatchWithArgs() throws Exception {
String expression = "execution(void test.beans.TestBean.setSomeNumber(Number)) && args(Double)"; String expression = "execution(void org.springframework.tests.sample.beans.TestBean.setSomeNumber(Number)) && args(Double)";
Pointcut pointcut = getPointcut(expression); Pointcut pointcut = getPointcut(expression);
ClassFilter classFilter = pointcut.getClassFilter(); ClassFilter classFilter = pointcut.getClassFilter();
@ -235,7 +235,7 @@ public final class AspectJExpressionPointcutTests {
@Test @Test
public void testSimpleAdvice() { public void testSimpleAdvice() {
String expression = "execution(int test.beans.TestBean.getAge())"; String expression = "execution(int org.springframework.tests.sample.beans.TestBean.getAge())";
CallCountingInterceptor interceptor = new CallCountingInterceptor(); CallCountingInterceptor interceptor = new CallCountingInterceptor();
@ -254,7 +254,7 @@ public final class AspectJExpressionPointcutTests {
@Test @Test
public void testDynamicMatchingProxy() { public void testDynamicMatchingProxy() {
String expression = "execution(void test.beans.TestBean.setSomeNumber(Number)) && args(Double)"; String expression = "execution(void org.springframework.tests.sample.beans.TestBean.setSomeNumber(Number)) && args(Double)";
CallCountingInterceptor interceptor = new CallCountingInterceptor(); CallCountingInterceptor interceptor = new CallCountingInterceptor();
@ -273,7 +273,7 @@ public final class AspectJExpressionPointcutTests {
@Test @Test
public void testInvalidExpression() { public void testInvalidExpression() {
String expression = "execution(void test.beans.TestBean.setSomeNumber(Number) && args(Double)"; String expression = "execution(void org.springframework.tests.sample.beans.TestBean.setSomeNumber(Number) && args(Double)";
try { try {
getPointcut(expression).getClassFilter(); // call to getClassFilter forces resolution getPointcut(expression).getClassFilter(); // call to getClassFilter forces resolution
@ -309,13 +309,9 @@ public final class AspectJExpressionPointcutTests {
assertTrue("Expression should match TestBean class", classFilter.matches(TestBean.class)); assertTrue("Expression should match TestBean class", classFilter.matches(TestBean.class));
} }
private void assertDoesNotMatchStringClass(ClassFilter classFilter) {
assertFalse("Expression should not match String class", classFilter.matches(String.class));
}
@Test @Test
public void testWithUnsupportedPointcutPrimitive() throws Exception { public void testWithUnsupportedPointcutPrimitive() throws Exception {
String expression = "call(int test.beans.TestBean.getAge())"; String expression = "call(int org.springframework.tests.sample.beans.TestBean.getAge())";
try { try {
getPointcut(expression).getClassFilter(); // call to getClassFilter forces resolution... getPointcut(expression).getClassFilter(); // call to getClassFilter forces resolution...

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -20,7 +20,7 @@ import static org.junit.Assert.*;
import org.junit.Test; import org.junit.Test;
import test.beans.TestBean; import org.springframework.tests.sample.beans.TestBean;
/** /**
* Tests for matching of bean() pointcut designator. * Tests for matching of bean() pointcut designator.

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -28,8 +28,8 @@ import org.aspectj.lang.reflect.SourceLocation;
import org.aspectj.runtime.reflect.Factory; import org.aspectj.runtime.reflect.Factory;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.junit.Test; import org.junit.Test;
import test.beans.ITestBean; import org.springframework.tests.sample.beans.ITestBean;
import test.beans.TestBean; import org.springframework.tests.sample.beans.TestBean;
import org.springframework.aop.MethodBeforeAdvice; import org.springframework.aop.MethodBeforeAdvice;
import org.springframework.aop.framework.AopContext; import org.springframework.aop.framework.AopContext;
@ -139,7 +139,7 @@ public final class MethodInvocationProceedingJoinPointTests {
@Override @Override
public void before(Method method, Object[] args, Object target) throws Throwable { public void before(Method method, Object[] args, Object target) throws Throwable {
SourceLocation sloc = AbstractAspectJAdvice.currentJoinPoint().getSourceLocation(); SourceLocation sloc = AbstractAspectJAdvice.currentJoinPoint().getSourceLocation();
assertEquals("Same source location must be returned on subsequent requests", sloc, AbstractAspectJAdvice.currentJoinPoint().getSourceLocation()); assertEquals("Same source location must be returned on subsequent requests", sloc, AbstractAspectJAdvice.currentJoinPoint().getSourceLocation());
assertEquals(TestBean.class, sloc.getWithinType()); assertEquals(TestBean.class, sloc.getWithinType());
try { try {
sloc.getLine(); sloc.getLine();
@ -172,7 +172,7 @@ public final class MethodInvocationProceedingJoinPointTests {
@Override @Override
public void before(Method method, Object[] args, Object target) throws Throwable { public void before(Method method, Object[] args, Object target) throws Throwable {
StaticPart staticPart = AbstractAspectJAdvice.currentJoinPoint().getStaticPart(); StaticPart staticPart = AbstractAspectJAdvice.currentJoinPoint().getStaticPart();
assertEquals("Same static part must be returned on subsequent requests", staticPart, AbstractAspectJAdvice.currentJoinPoint().getStaticPart()); assertEquals("Same static part must be returned on subsequent requests", staticPart, AbstractAspectJAdvice.currentJoinPoint().getStaticPart());
assertEquals(ProceedingJoinPoint.METHOD_EXECUTION, staticPart.getKind()); assertEquals(ProceedingJoinPoint.METHOD_EXECUTION, staticPart.getKind());
assertSame(AbstractAspectJAdvice.currentJoinPoint().getSignature(), staticPart.getSignature()); assertSame(AbstractAspectJAdvice.currentJoinPoint().getSignature(), staticPart.getSignature());
assertEquals(AbstractAspectJAdvice.currentJoinPoint().getSourceLocation(), staticPart.getSourceLocation()); assertEquals(AbstractAspectJAdvice.currentJoinPoint().getSourceLocation(), staticPart.getSourceLocation());

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -29,7 +29,7 @@ import org.junit.Test;
import test.annotation.EmptySpringAnnotation; import test.annotation.EmptySpringAnnotation;
import test.annotation.transaction.Tx; import test.annotation.transaction.Tx;
import test.beans.TestBean; import org.springframework.tests.sample.beans.TestBean;
/** /**
@ -70,7 +70,7 @@ public final class TigerAspectJExpressionPointcutTests {
@Test @Test
public void testMatchGenericArgument() { public void testMatchGenericArgument() {
String expression = "execution(* set*(java.util.List<test.beans.TestBean>) )"; String expression = "execution(* set*(java.util.List<org.springframework.tests.sample.beans.TestBean>) )";
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut(); AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
ajexp.setExpression(expression); ajexp.setExpression(expression);
@ -89,6 +89,8 @@ public final class TigerAspectJExpressionPointcutTests {
@Test @Test
public void testMatchVarargs() throws SecurityException, NoSuchMethodException { public void testMatchVarargs() throws SecurityException, NoSuchMethodException {
@SuppressWarnings("unused")
class MyTemplate { class MyTemplate {
public int queryForInt(String sql, Object... params) { public int queryForInt(String sql, Object... params) {
return 0; return 0;

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,11 +22,11 @@ import org.junit.Test;
import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import test.beans.CountingTestBean; import org.springframework.tests.sample.beans.CountingTestBean;
import test.beans.IOther; import org.springframework.tests.sample.beans.IOther;
import test.beans.ITestBean; import org.springframework.tests.sample.beans.ITestBean;
import test.beans.TestBean; import org.springframework.tests.sample.beans.TestBean;
import test.beans.subpkg.DeepBean; import org.springframework.tests.sample.beans.subpkg.DeepBean;
/** /**
* Unit tests for the {@link TypePatternClassFilter} class. * Unit tests for the {@link TypePatternClassFilter} class.
@ -45,7 +45,7 @@ public final class TypePatternClassFilterTests {
@Test @Test
public void testValidPatternMatching() { public void testValidPatternMatching() {
TypePatternClassFilter tpcf = new TypePatternClassFilter("test.beans.*"); TypePatternClassFilter tpcf = new TypePatternClassFilter("org.springframework.tests.sample.beans.*");
assertTrue("Must match: in package", tpcf.matches(TestBean.class)); assertTrue("Must match: in package", tpcf.matches(TestBean.class));
assertTrue("Must match: in package", tpcf.matches(ITestBean.class)); assertTrue("Must match: in package", tpcf.matches(ITestBean.class));
assertTrue("Must match: in package", tpcf.matches(IOther.class)); assertTrue("Must match: in package", tpcf.matches(IOther.class));
@ -56,7 +56,7 @@ public final class TypePatternClassFilterTests {
@Test @Test
public void testSubclassMatching() { public void testSubclassMatching() {
TypePatternClassFilter tpcf = new TypePatternClassFilter("test.beans.ITestBean+"); TypePatternClassFilter tpcf = new TypePatternClassFilter("org.springframework.tests.sample.beans.ITestBean+");
assertTrue("Must match: in package", tpcf.matches(TestBean.class)); assertTrue("Must match: in package", tpcf.matches(TestBean.class));
assertTrue("Must match: in package", tpcf.matches(ITestBean.class)); assertTrue("Must match: in package", tpcf.matches(ITestBean.class));
assertTrue("Must match: in package", tpcf.matches(CountingTestBean.class)); assertTrue("Must match: in package", tpcf.matches(CountingTestBean.class));

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +15,14 @@
*/ */
package org.springframework.aop.aspectj.annotation; package org.springframework.aop.aspectj.annotation;
import static org.junit.Assert.*; import static org.hamcrest.Matchers.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
@ -39,9 +46,7 @@ import org.aspectj.lang.annotation.DeclareParents;
import org.aspectj.lang.annotation.DeclarePrecedence; import org.aspectj.lang.annotation.DeclarePrecedence;
import org.aspectj.lang.annotation.Pointcut; import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature; import org.aspectj.lang.reflect.MethodSignature;
import org.junit.Test; import org.junit.Test;
import org.springframework.aop.Advisor; import org.springframework.aop.Advisor;
import org.springframework.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactory.SyntheticInstantiationAdvisor; import org.springframework.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactory.SyntheticInstantiationAdvisor;
import org.springframework.aop.framework.Advised; import org.springframework.aop.framework.Advised;
@ -52,14 +57,14 @@ import org.springframework.aop.support.AopUtils;
import org.springframework.core.OrderComparator; import org.springframework.core.OrderComparator;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order; 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 org.springframework.util.ObjectUtils;
import test.aop.DefaultLockable; import test.aop.DefaultLockable;
import test.aop.Lockable; import test.aop.Lockable;
import test.aop.PerTargetAspect; import test.aop.PerTargetAspect;
import test.aop.TwoAdviceAspect; import test.aop.TwoAdviceAspect;
import test.beans.ITestBean;
import test.beans.TestBean;
/** /**
* Abstract tests for AspectJAdvisorFactory. * Abstract tests for AspectJAdvisorFactory.
@ -385,7 +390,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
CannotBeUnlocked.class CannotBeUnlocked.class
), ),
CannotBeUnlocked.class); CannotBeUnlocked.class);
assertTrue(proxy instanceof Lockable); assertThat(proxy, instanceOf(Lockable.class));
Lockable lockable = proxy; Lockable lockable = proxy;
assertTrue("Already locked", lockable.locked()); assertTrue("Already locked", lockable.locked());
lockable.lock(); lockable.lock();
@ -399,7 +404,6 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
} }
} }
@SuppressWarnings("unchecked")
@Test @Test
public void testIntroductionOnTargetExcludedByTypePattern() { public void testIntroductionOnTargetExcludedByTypePattern() {
LinkedList target = new LinkedList(); LinkedList target = new LinkedList();
@ -442,7 +446,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
Modifiable modifiable = (Modifiable) createProxy(target, Modifiable modifiable = (Modifiable) createProxy(target,
advisors, advisors,
ITestBean.class); ITestBean.class);
assertTrue(modifiable instanceof Modifiable); assertThat(modifiable, instanceOf(Modifiable.class));
Lockable lockable = (Lockable) modifiable; Lockable lockable = (Lockable) modifiable;
assertFalse(lockable.locked()); assertFalse(lockable.locked());
@ -650,7 +654,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
} }
@Aspect("pertypewithin(test.beans.IOther+)") @Aspect("pertypewithin(org.springframework.tests.sample.beans.IOther+)")
public static class PerTypeWithinAspect { public static class PerTypeWithinAspect {
public int count; public int count;
@ -936,7 +940,7 @@ abstract class AbstractMakeModifiable {
} }
// Find the current raw value, by invoking the corresponding setter // Find the current raw value, by invoking the corresponding setter
Method correspondingGetter = getGetterFromSetter(((MethodSignature) jp.getSignature()).getMethod()); Method correspondingGetter = getGetterFromSetter(((MethodSignature) jp.getSignature()).getMethod());
boolean modified = true; boolean modified = true;
if (correspondingGetter != null) { if (correspondingGetter != null) {
try { try {
@ -979,7 +983,7 @@ abstract class AbstractMakeModifiable {
@Aspect @Aspect
class MakeITestBeanModifiable extends AbstractMakeModifiable { class MakeITestBeanModifiable extends AbstractMakeModifiable {
@DeclareParents(value = "test.beans.ITestBean+", @DeclareParents(value = "org.springframework.tests.sample.beans.ITestBean+",
defaultImpl=ModifiableImpl.class) defaultImpl=ModifiableImpl.class)
public static MutableModifable mixin; public static MutableModifable mixin;

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -29,8 +29,8 @@ import org.aspectj.lang.annotation.Pointcut;
import org.junit.Test; import org.junit.Test;
import org.springframework.aop.aspectj.AspectJAdviceParameterNameDiscoverer; import org.springframework.aop.aspectj.AspectJAdviceParameterNameDiscoverer;
import test.beans.ITestBean; import org.springframework.tests.sample.beans.ITestBean;
import test.beans.TestBean; import org.springframework.tests.sample.beans.TestBean;
/** /**
* @author Adrian Colyer * @author Adrian Colyer

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -25,7 +25,7 @@ import org.springframework.aop.aspectj.AspectJExpressionPointcutTests;
import org.springframework.aop.framework.AopConfigException; import org.springframework.aop.framework.AopConfigException;
import test.aop.PerTargetAspect; import test.aop.PerTargetAspect;
import test.beans.TestBean; import org.springframework.tests.sample.beans.TestBean;
/** /**

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,14 +16,16 @@
package org.springframework.aop.aspectj.annotation; package org.springframework.aop.aspectj.annotation;
import static org.junit.Assert.assertEquals;
import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Aspect;
import static org.junit.Assert.*;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.springframework.util.SerializationTestUtils;
import test.aop.PerThisAspect; import test.aop.PerThisAspect;
import test.util.SerializationTestUtils;
/** /**
* @author Rob Harrop * @author Rob Harrop

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2008 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,7 @@
package org.springframework.aop.aspectj.autoproxy; package org.springframework.aop.aspectj.autoproxy;
import static org.junit.Assert.*; import static org.junit.Assert.assertEquals;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -30,8 +30,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.ParserContext; import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.beans.factory.xml.XmlReaderContext; import org.springframework.beans.factory.xml.XmlReaderContext;
import org.springframework.tests.beans.CollectingReaderEventListener;
import test.parsing.CollectingReaderEventListener;
/** /**
* @author Rob Harrop * @author Rob Harrop

11
spring-aop/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJPrecedenceComparatorTests.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,12 +16,11 @@
package org.springframework.aop.aspectj.autoproxy; package org.springframework.aop.aspectj.autoproxy;
import static org.junit.Assert.*;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.springframework.aop.Advisor; import org.springframework.aop.Advisor;
import org.springframework.aop.AfterReturningAdvice; import org.springframework.aop.AfterReturningAdvice;
import org.springframework.aop.BeforeAdvice; import org.springframework.aop.BeforeAdvice;
@ -35,11 +34,13 @@ import org.springframework.aop.aspectj.AspectJMethodBeforeAdvice;
import org.springframework.aop.aspectj.AspectJPointcutAdvisor; import org.springframework.aop.aspectj.AspectJPointcutAdvisor;
import org.springframework.aop.support.DefaultPointcutAdvisor; import org.springframework.aop.support.DefaultPointcutAdvisor;
import static org.junit.Assert.*;
/** /**
* @author Adrian Colyer * @author Adrian Colyer
* @author Chris Beams * @author Chris Beams
*/ */
public final class AspectJPrecedenceComparatorTests { public class AspectJPrecedenceComparatorTests {
private static final int HIGH_PRECEDENCE_ADVISOR_ORDER = 100; private static final int HIGH_PRECEDENCE_ADVISOR_ORDER = 100;
private static final int LOW_PRECEDENCE_ADVISOR_ORDER = 200; private static final int LOW_PRECEDENCE_ADVISOR_ORDER = 200;
@ -89,7 +90,7 @@ public final class AspectJPrecedenceComparatorTests {
public void testSameAspectOneOfEach() { public void testSameAspectOneOfEach() {
Advisor advisor1 = createAspectJAfterAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect"); Advisor advisor1 = createAspectJAfterAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect");
Advisor advisor2 = createAspectJBeforeAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, LATE_ADVICE_DECLARATION_ORDER, "someAspect"); Advisor advisor2 = createAspectJBeforeAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, LATE_ADVICE_DECLARATION_ORDER, "someAspect");
assertEquals("advisor1 and advisor2 not comparable", 0, this.comparator.compare(advisor1, advisor2)); assertEquals("advisor1 and advisor2 not comparable", 1, this.comparator.compare(advisor1, advisor2));
} }
@Test @Test

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

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

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,8 +16,10 @@
package org.springframework.aop.config; package org.springframework.aop.config;
import static org.junit.Assert.*; import static org.junit.Assert.assertEquals;
import static test.util.TestResourceUtils.qualifiedResource; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.springframework.tests.TestResourceUtils.qualifiedResource;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@ -32,8 +34,7 @@ import org.springframework.beans.factory.parsing.CompositeComponentDefinition;
import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.tests.beans.CollectingReaderEventListener;
import test.parsing.CollectingReaderEventListener;
/** /**
* @author Rob Harrop * @author Rob Harrop

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

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

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

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

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,7 +18,7 @@ package org.springframework.aop.config;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static test.util.TestResourceUtils.qualifiedResource; import static org.springframework.tests.TestResourceUtils.qualifiedResource;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.beans.factory.BeanDefinitionStoreException;

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,7 +17,7 @@
package org.springframework.aop.config; package org.springframework.aop.config;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static test.util.TestResourceUtils.qualifiedResource; import static org.springframework.tests.TestResourceUtils.qualifiedResource;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory;

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -27,8 +27,8 @@ import java.util.List;
import org.junit.Test; import org.junit.Test;
import org.springframework.aop.SpringProxy; import org.springframework.aop.SpringProxy;
import test.beans.ITestBean; import org.springframework.tests.sample.beans.ITestBean;
import test.beans.TestBean; import org.springframework.tests.sample.beans.TestBean;
/** /**
* @author Rod Johnson * @author Rod Johnson
@ -137,4 +137,4 @@ public final class AopProxyUtilsTests {
AopProxyUtils.proxiedUserInterfaces(proxy); AopProxyUtils.proxiedUserInterfaces(proxy);
} }
} }

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -20,8 +20,8 @@ import org.junit.Test;
import org.springframework.aop.support.DelegatingIntroductionInterceptor; import org.springframework.aop.support.DelegatingIntroductionInterceptor;
import org.springframework.util.StopWatch; import org.springframework.util.StopWatch;
import test.beans.ITestBean; import org.springframework.tests.sample.beans.ITestBean;
import test.beans.TestBean; import org.springframework.tests.sample.beans.TestBean;
/** /**
* Benchmarks for introductions. * Benchmarks for introductions.

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -26,7 +26,7 @@ import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation; import org.aopalliance.intercept.MethodInvocation;
import org.junit.Test; import org.junit.Test;
import test.beans.TestBean; import org.springframework.tests.sample.beans.TestBean;
/** /**
* @author Rod Johnson * @author Rod Johnson

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,7 +17,7 @@
package org.springframework.aop.framework; package org.springframework.aop.framework;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static test.util.TestResourceUtils.qualifiedResource; import static org.springframework.tests.TestResourceUtils.qualifiedResource;
import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation; import org.aopalliance.intercept.MethodInvocation;
@ -63,7 +63,6 @@ public final class PrototypeTargetTests {
assertEquals(10, interceptor.invocationCount); assertEquals(10, interceptor.invocationCount);
} }
public static interface TestBean { public static interface TestBean {
public void doSomething(); public void doSomething();
} }

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,28 +16,33 @@
package org.springframework.aop.framework; package org.springframework.aop.framework;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import javax.accessibility.Accessible; import javax.accessibility.Accessible;
import javax.swing.*; import javax.swing.JFrame;
import javax.swing.RootPaneContainer;
import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation; import org.aopalliance.intercept.MethodInvocation;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import test.aop.CountingBeforeAdvice;
import test.aop.NopInterceptor;
import test.beans.IOther;
import test.beans.ITestBean;
import test.beans.TestBean;
import test.util.TimeStamped;
import org.springframework.aop.Advisor; import org.springframework.aop.Advisor;
import org.springframework.aop.interceptor.DebugInterceptor; import org.springframework.aop.interceptor.DebugInterceptor;
import org.springframework.aop.support.AopUtils; import org.springframework.aop.support.AopUtils;
import org.springframework.aop.support.DefaultIntroductionAdvisor; import org.springframework.aop.support.DefaultIntroductionAdvisor;
import org.springframework.aop.support.DefaultPointcutAdvisor; import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.aop.support.DelegatingIntroductionInterceptor; import org.springframework.aop.support.DelegatingIntroductionInterceptor;
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;
/** /**
* Also tests AdvisedSupport and ProxyCreatorSupport superclasses. * Also tests AdvisedSupport and ProxyCreatorSupport superclasses.
@ -190,7 +195,7 @@ public final class ProxyFactoryTests {
TestBeanSubclass raw = new TestBeanSubclass(); TestBeanSubclass raw = new TestBeanSubclass();
ProxyFactory factory = new ProxyFactory(raw); ProxyFactory factory = new ProxyFactory(raw);
//System.out.println("Proxied interfaces are " + StringUtils.arrayToDelimitedString(factory.getProxiedInterfaces(), ",")); //System.out.println("Proxied interfaces are " + StringUtils.arrayToDelimitedString(factory.getProxiedInterfaces(), ","));
assertEquals("Found correct number of interfaces", 3, factory.getProxiedInterfaces().length); assertEquals("Found correct number of interfaces", 5, factory.getProxiedInterfaces().length);
ITestBean tb = (ITestBean) factory.getProxy(); ITestBean tb = (ITestBean) factory.getProxy();
assertThat("Picked up secondary interface", tb, instanceOf(IOther.class)); assertThat("Picked up secondary interface", tb, instanceOf(IOther.class));

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,21 +16,23 @@
package org.springframework.aop.framework.adapter; package org.springframework.aop.framework.adapter;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import javax.transaction.TransactionRolledbackException; import javax.transaction.TransactionRolledbackException;
import org.aopalliance.intercept.MethodInvocation; import org.aopalliance.intercept.MethodInvocation;
import static org.junit.Assert.*;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
import org.junit.Test; import org.junit.Test;
import test.aop.MethodCounter;
import org.springframework.aop.ThrowsAdvice; import org.springframework.aop.ThrowsAdvice;
import org.springframework.tests.aop.advice.MethodCounter;
/** /**
* @author Rod Johnson * @author Rod Johnson
@ -142,7 +144,7 @@ public final class ThrowsAdviceInterceptorTests {
} }
@SuppressWarnings("serial") @SuppressWarnings("serial")
private static class MyThrowsHandler extends MethodCounter implements ThrowsAdvice { static class MyThrowsHandler extends MethodCounter implements ThrowsAdvice {
// Full method signature // Full method signature
public void afterThrowing(Method m, Object[] args, Object target, IOException ex) { public void afterThrowing(Method m, Object[] args, Object target, IOException ex) {
count("ioException"); count("ioException");

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,19 +16,17 @@
package org.springframework.aop.interceptor; package org.springframework.aop.interceptor;
import static org.junit.Assert.*; import static org.junit.Assert.assertEquals;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.junit.Test; import org.junit.Test;
import org.springframework.aop.framework.Advised; import org.springframework.aop.framework.Advised;
import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.framework.ProxyFactory;
import org.springframework.tests.sample.beans.DerivedTestBean;
import test.beans.DerivedTestBean; import org.springframework.tests.sample.beans.ITestBean;
import test.beans.ITestBean; import org.springframework.tests.sample.beans.TestBean;
import test.beans.TestBean; import org.springframework.util.SerializationTestUtils;
import test.util.SerializationTestUtils;
/** /**
* @author Juergen Hoeller * @author Juergen Hoeller

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -24,8 +24,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import java.lang.reflect.Method;
import org.aopalliance.intercept.MethodInvocation; import org.aopalliance.intercept.MethodInvocation;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.junit.Test; import org.junit.Test;

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,8 +22,8 @@ import org.junit.Test;
import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.factory.NamedBean; import org.springframework.beans.factory.NamedBean;
import test.beans.ITestBean; import org.springframework.tests.sample.beans.ITestBean;
import test.beans.TestBean; import org.springframework.tests.sample.beans.TestBean;
/** /**
* @author Rod Johnson * @author Rod Johnson

12
spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests-context.xml

@ -5,8 +5,8 @@
Tests for throws advice. Tests for throws advice.
--> -->
<beans> <beans>
<bean id="nopInterceptor" class="test.aop.NopInterceptor"/> <bean id="nopInterceptor" class="org.springframework.tests.aop.interceptor.NopInterceptor"/>
<bean id="exposeInvocation" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean"> <bean id="exposeInvocation" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
<property name="targetClass"> <property name="targetClass">
@ -14,8 +14,8 @@
</property> </property>
<property name="targetField"><value>INSTANCE</value></property> <property name="targetField"><value>INSTANCE</value></property>
</bean> </bean>
<bean id="countingBeforeAdvice" class="test.aop.CountingBeforeAdvice"/> <bean id="countingBeforeAdvice" class="org.springframework.tests.aop.advice.CountingBeforeAdvice"/>
<bean id="proxy" class="org.springframework.aop.framework.ProxyFactoryBean"> <bean id="proxy" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="target"> <property name="target">
@ -25,5 +25,5 @@
<value>exposeInvocation,countingBeforeAdvice,nopInterceptor</value> <value>exposeInvocation,countingBeforeAdvice,nopInterceptor</value>
</property> </property>
</bean> </bean>
</beans> </beans>

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,16 +18,15 @@ package org.springframework.aop.interceptor;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static test.util.TestResourceUtils.qualifiedResource; import static org.springframework.tests.TestResourceUtils.qualifiedResource;
import org.aopalliance.intercept.MethodInvocation; import org.aopalliance.intercept.MethodInvocation;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.tests.sample.beans.ITestBean;
import test.beans.ITestBean; import org.springframework.tests.sample.beans.TestBean;
import test.beans.TestBean;
/** /**
* Non-XML tests are in AbstractAopProxyTests * Non-XML tests are in AbstractAopProxyTests
@ -45,7 +44,7 @@ public final class ExposeInvocationInterceptorTests {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT); new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
ITestBean tb = (ITestBean) bf.getBean("proxy"); ITestBean tb = (ITestBean) bf.getBean("proxy");
String name= "tony"; String name = "tony";
tb.setName(name); tb.setName(name);
// Fires context checks // Fires context checks
assertEquals(name, tb.getName()); assertEquals(name, tb.getName());

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -24,8 +24,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import java.lang.reflect.Method;
import org.aopalliance.intercept.MethodInvocation; import org.aopalliance.intercept.MethodInvocation;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.junit.Test; import org.junit.Test;

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,7 +17,7 @@
package org.springframework.aop.scope; package org.springframework.aop.scope;
import static org.junit.Assert.assertSame; import static org.junit.Assert.assertSame;
import static test.util.TestResourceUtils.qualifiedResource; import static org.springframework.tests.TestResourceUtils.qualifiedResource;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory;

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2008 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,15 +16,16 @@
package org.springframework.aop.support; package org.springframework.aop.support;
import static org.junit.Assert.*; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.IOException; import java.io.IOException;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.springframework.tests.sample.beans.TestBean;
import test.beans.TestBean; import org.springframework.util.SerializationTestUtils;
import test.util.SerializationTestUtils;
/** /**
* @author Rod Johnson * @author Rod Johnson

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,9 @@
package org.springframework.aop.support; package org.springframework.aop.support;
import static org.junit.Assert.*; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -26,10 +28,10 @@ import org.springframework.aop.MethodMatcher;
import org.springframework.aop.Pointcut; import org.springframework.aop.Pointcut;
import org.springframework.aop.interceptor.ExposeInvocationInterceptor; import org.springframework.aop.interceptor.ExposeInvocationInterceptor;
import org.springframework.aop.target.EmptyTargetSource; import org.springframework.aop.target.EmptyTargetSource;
import org.springframework.tests.aop.interceptor.NopInterceptor;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.util.SerializationTestUtils;
import test.aop.NopInterceptor;
import test.beans.TestBean;
import test.util.SerializationTestUtils;
/** /**
* @author Rod Johnson * @author Rod Johnson

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,8 +22,8 @@ import org.junit.Test;
import org.springframework.aop.ClassFilter; import org.springframework.aop.ClassFilter;
import org.springframework.core.NestedRuntimeException; import org.springframework.core.NestedRuntimeException;
import test.beans.ITestBean; import org.springframework.tests.sample.beans.ITestBean;
import test.beans.TestBean; import org.springframework.tests.sample.beans.TestBean;
/** /**
* @author Rod Johnson * @author Rod Johnson

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2009 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,7 +18,7 @@ package org.springframework.aop.support;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.framework.ProxyFactory;
import test.beans.TestBean; import org.springframework.tests.sample.beans.TestBean;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
/** /**

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -26,7 +26,7 @@ import org.springframework.aop.MethodMatcher;
import org.springframework.aop.Pointcut; import org.springframework.aop.Pointcut;
import org.springframework.core.NestedRuntimeException; import org.springframework.core.NestedRuntimeException;
import test.beans.TestBean; import org.springframework.tests.sample.beans.TestBean;
/** /**
* @author Rod Johnson * @author Rod Johnson

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,15 +16,16 @@
package org.springframework.aop.support; package org.springframework.aop.support;
import static org.junit.Assert.*; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import org.junit.Test; import org.junit.Test;
import org.springframework.aop.Pointcut; import org.springframework.aop.Pointcut;
import org.springframework.aop.framework.ProxyFactory; 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 test.aop.NopInterceptor;
import test.beans.ITestBean;
import test.beans.TestBean;
/** /**
* @author Rod Johnson * @author Rod Johnson

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,11 @@
package org.springframework.aop.support; package org.springframework.aop.support;
import static org.junit.Assert.*; import static org.hamcrest.Matchers.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
@ -27,16 +31,15 @@ import org.junit.Test;
import org.springframework.aop.IntroductionAdvisor; import org.springframework.aop.IntroductionAdvisor;
import org.springframework.aop.IntroductionInterceptor; import org.springframework.aop.IntroductionInterceptor;
import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.framework.ProxyFactory;
import org.springframework.tests.TimeStamped;
import test.aop.SerializableNopInterceptor; import org.springframework.tests.aop.interceptor.SerializableNopInterceptor;
import test.beans.INestedTestBean; import org.springframework.tests.sample.beans.INestedTestBean;
import test.beans.ITestBean; import org.springframework.tests.sample.beans.ITestBean;
import test.beans.NestedTestBean; import org.springframework.tests.sample.beans.NestedTestBean;
import test.beans.Person; import org.springframework.tests.sample.beans.Person;
import test.beans.SerializablePerson; import org.springframework.tests.sample.beans.SerializablePerson;
import test.beans.TestBean; import org.springframework.tests.sample.beans.TestBean;
import test.util.SerializationTestUtils; import org.springframework.util.SerializationTestUtils;
import test.util.TimeStamped;
/** /**
* @author Rod Johnson * @author Rod Johnson
@ -156,7 +159,7 @@ public final class DelegatingIntroductionInterceptorTests {
//assertTrue(Arrays.binarySearch(pf.getProxiedInterfaces(), TimeStamped.class) != -1); //assertTrue(Arrays.binarySearch(pf.getProxiedInterfaces(), TimeStamped.class) != -1);
TimeStamped ts = (TimeStamped) pf.getProxy(); TimeStamped ts = (TimeStamped) pf.getProxy();
assertTrue(ts instanceof TimeStamped); assertThat(ts, instanceOf(TimeStamped.class));
// Shoulnd't proxy framework interfaces // Shoulnd't proxy framework interfaces
assertTrue(!(ts instanceof MethodInterceptor)); assertTrue(!(ts instanceof MethodInterceptor));
assertTrue(!(ts instanceof IntroductionInterceptor)); assertTrue(!(ts instanceof IntroductionInterceptor));

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,17 +16,18 @@
package org.springframework.aop.support; package org.springframework.aop.support;
import static org.junit.Assert.*; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import org.junit.Test; import org.junit.Test;
import org.springframework.aop.MethodMatcher; import org.springframework.aop.MethodMatcher;
import org.springframework.tests.sample.beans.IOther;
import test.beans.IOther; import org.springframework.tests.sample.beans.ITestBean;
import test.beans.ITestBean; import org.springframework.tests.sample.beans.TestBean;
import test.beans.TestBean; import org.springframework.util.SerializationTestUtils;
import test.util.SerializationTestUtils;
/** /**
* @author Juergen Hoeller * @author Juergen Hoeller

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,18 +16,20 @@
package org.springframework.aop.support; package org.springframework.aop.support;
import static org.junit.Assert.*; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.springframework.aop.framework.Advised; import org.springframework.aop.framework.Advised;
import org.springframework.aop.framework.ProxyFactory; 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 test.aop.NopInterceptor;
import test.aop.SerializableNopInterceptor;
import test.beans.Person;
import test.beans.SerializablePerson;
import test.util.SerializationTestUtils;
/** /**
* @author Rod Johnson * @author Rod Johnson

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -24,7 +24,7 @@ import org.junit.Test;
import org.springframework.aop.ClassFilter; import org.springframework.aop.ClassFilter;
import org.springframework.aop.Pointcut; import org.springframework.aop.Pointcut;
import test.beans.TestBean; import org.springframework.tests.sample.beans.TestBean;
/** /**
* @author Rod Johnson * @author Rod Johnson

22
spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests-context.xml

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

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,20 +17,20 @@
package org.springframework.aop.support; package org.springframework.aop.support;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static test.util.TestResourceUtils.qualifiedResource; import static org.springframework.tests.TestResourceUtils.qualifiedResource;
import org.junit.Test; import org.junit.Test;
import org.springframework.aop.framework.Advised; import org.springframework.aop.framework.Advised;
import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.Resource; 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 test.aop.NopInterceptor;
import test.aop.SerializableNopInterceptor;
import test.beans.ITestBean;
import test.beans.Person;
import test.beans.TestBean;
import test.util.SerializationTestUtils;
/** /**
* @author Rod Johnson * @author Rod Johnson

2
spring-aop/src/test/java/org/springframework/aop/target/CommonsPoolTargetSourceProxyTests-context.xml

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

7
spring-aop/src/test/java/org/springframework/aop/target/CommonsPoolTargetSourceProxyTests.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,15 +17,14 @@
package org.springframework.aop.target; package org.springframework.aop.target;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static test.util.TestResourceUtils.qualifiedResource; import static org.springframework.tests.TestResourceUtils.qualifiedResource;
import org.junit.Test; import org.junit.Test;
import org.springframework.aop.support.AopUtils; import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.tests.sample.beans.ITestBean;
import test.beans.ITestBean;
/** /**
* @author Rob Harrop * @author Rob Harrop

11
spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests-context.xml

@ -4,15 +4,15 @@
<beans> <beans>
<!-- Simple target --> <!-- Simple target -->
<bean id="target1" class="test.beans.SideEffectBean"> <bean id="target1" class="org.springframework.tests.sample.beans.SideEffectBean">
<property name="count"><value>10</value></property> <property name="count"><value>10</value></property>
</bean> </bean>
<bean id="target2" class="test.beans.SideEffectBean" scope="singleton"> <bean id="target2" class="org.springframework.tests.sample.beans.SideEffectBean" scope="singleton">
<property name="count"><value>20</value></property> <property name="count"><value>20</value></property>
</bean> </bean>
<!-- <!--
Hot swappable target source. Note the use of Type 3 IoC. Hot swappable target source. Note the use of Type 3 IoC.
--> -->
<bean id="swapper" class="org.springframework.aop.target.HotSwappableTargetSource"> <bean id="swapper" class="org.springframework.aop.target.HotSwappableTargetSource">
@ -23,5 +23,4 @@
<property name="targetSource"><ref local="swapper"/></property> <property name="targetSource"><ref local="swapper"/></property>
</bean> </bean>
</beans> </beans>

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,7 +19,7 @@ package org.springframework.aop.target;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static test.util.TestResourceUtils.qualifiedResource; import static org.springframework.tests.TestResourceUtils.qualifiedResource;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
@ -30,12 +30,12 @@ import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
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 test.aop.SerializableNopInterceptor;
import test.beans.Person;
import test.beans.SerializablePerson;
import test.beans.SideEffectBean;
import test.util.SerializationTestUtils;
/** /**

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

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

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

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

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,7 +19,7 @@ package org.springframework.aop.target;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static test.util.TestResourceUtils.qualifiedResource; import static org.springframework.tests.TestResourceUtils.qualifiedResource;
import java.util.Set; import java.util.Set;
@ -27,8 +27,7 @@ import org.junit.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.tests.sample.beans.ITestBean;
import test.beans.ITestBean;
/** /**
* @author Juergen Hoeller * @author Juergen Hoeller

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,17 +16,17 @@
package org.springframework.aop.target; package org.springframework.aop.target;
import static org.junit.Assert.*; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test; import org.junit.Test;
import org.springframework.aop.TargetSource; import org.springframework.aop.TargetSource;
import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.tests.sample.beans.SerializablePerson;
import test.beans.SerializablePerson; import org.springframework.tests.sample.beans.TestBean;
import test.beans.TestBean; import org.springframework.util.SerializationTestUtils;
import test.util.SerializationTestUtils;
/** /**
* Unit tests relating to the abstract {@link AbstractPrototypeBasedTargetSource} * Unit tests relating to the abstract {@link AbstractPrototypeBasedTargetSource}

16
spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests-context.xml

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

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,7 +17,7 @@
package org.springframework.aop.target; package org.springframework.aop.target;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static test.util.TestResourceUtils.qualifiedResource; import static org.springframework.tests.TestResourceUtils.qualifiedResource;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -26,8 +26,7 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.tests.sample.beans.SideEffectBean;
import test.beans.SideEffectBean;
/** /**

33
spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests-context.xml

@ -2,17 +2,17 @@
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans> <beans>
<bean id="prototypeTest" class="test.beans.SideEffectBean" scope="prototype"> <bean id="prototypeTest" class="org.springframework.tests.sample.beans.SideEffectBean" scope="prototype">
<property name="count"><value>10</value></property> <property name="count"><value>10</value></property>
</bean> </bean>
<bean id="threadLocalTs" class="org.springframework.aop.target.ThreadLocalTargetSource"> <bean id="threadLocalTs" class="org.springframework.aop.target.ThreadLocalTargetSource">
<property name="targetBeanName"><value>prototypeTest</value></property> <property name="targetBeanName"><value>prototypeTest</value></property>
</bean> </bean>
<bean id="debugInterceptor" class="test.aop.NopInterceptor" /> <bean id="debugInterceptor" class="org.springframework.tests.aop.interceptor.NopInterceptor" />
<!-- <!--
We want to invoke the getStatsMixin method on our ThreadLocal invoker We want to invoke the getStatsMixin method on our ThreadLocal invoker
--> -->
@ -20,7 +20,7 @@
<property name="targetObject"><ref local="threadLocalTs" /></property> <property name="targetObject"><ref local="threadLocalTs" /></property>
<property name="targetMethod"><value>getStatsMixin</value></property> <property name="targetMethod"><value>getStatsMixin</value></property>
</bean> </bean>
<!-- <!--
This will create a bean for each thread ("apartment") This will create a bean for each thread ("apartment")
--> -->
@ -33,23 +33,22 @@
</bean> </bean>
<!-- ================ Definitions for second ThreadLocalTargetSource ====== --> <!-- ================ Definitions for second ThreadLocalTargetSource ====== -->
<bean id="test" class="test.beans.TestBean" scope="prototype"> <bean id="test" class="org.springframework.tests.sample.beans.TestBean" scope="prototype">
<property name="name"><value>Rod</value></property> <property name="name"><value>Rod</value></property>
<property name="spouse"><ref local="wife"/></property> <property name="spouse"><ref local="wife"/></property>
</bean> </bean>
<bean id="wife" class="test.beans.TestBean"> <bean id="wife" class="org.springframework.tests.sample.beans.TestBean">
<property name="name"><value>Kerry</value></property> <property name="name"><value>Kerry</value></property>
</bean> </bean>
<bean id="threadLocalTs2" class="org.springframework.aop.target.ThreadLocalTargetSource"> <bean id="threadLocalTs2" class="org.springframework.aop.target.ThreadLocalTargetSource">
<property name="targetBeanName"><value>test</value></property> <property name="targetBeanName"><value>test</value></property>
</bean> </bean>
<bean id="threadLocal2" class="org.springframework.aop.framework.ProxyFactoryBean"> <bean id="threadLocal2" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="targetSource"><ref local="threadLocalTs2"/></property> <property name="targetSource"><ref local="threadLocalTs2"/></property>
</bean> </bean>
</beans> </beans>

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,16 +19,15 @@ package org.springframework.aop.target;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static test.util.TestResourceUtils.qualifiedResource; import static org.springframework.tests.TestResourceUtils.qualifiedResource;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.tests.sample.beans.ITestBean;
import test.beans.ITestBean; import org.springframework.tests.sample.beans.SideEffectBean;
import test.beans.SideEffectBean;
/** /**

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

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package test.advice; package org.springframework.tests.aop.advice;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -33,4 +33,4 @@ public class CountingAfterReturningAdvice extends MethodCounter implements After
count(m); count(m);
} }
} }

2
spring-aop/src/test/java/test/aop/CountingBeforeAdvice.java → spring-aop/src/test/java/org/springframework/tests/aop/advice/CountingBeforeAdvice.java

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package test.aop; package org.springframework.tests.aop.advice;
import java.lang.reflect.Method; import java.lang.reflect.Method;

2
src/test/java/test/advice/MethodCounter.java → spring-aop/src/test/java/org/springframework/tests/aop/advice/MethodCounter.java

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package test.advice; package org.springframework.tests.aop.advice;
import java.io.Serializable; import java.io.Serializable;
import java.lang.reflect.Method; import java.lang.reflect.Method;

4
spring-context/src/test/java/test/advice/MyThrowsHandler.java → spring-aop/src/test/java/org/springframework/tests/aop/advice/MyThrowsHandler.java

@ -1,7 +1,7 @@
/** /**
* *
*/ */
package test.advice; package org.springframework.tests.aop.advice;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -24,4 +24,4 @@ public class MyThrowsHandler extends MethodCounter implements ThrowsAdvice {
public void afterThrowing(Method m, Exception ex) throws Throwable { public void afterThrowing(Method m, Exception ex) throws Throwable {
throw new UnsupportedOperationException("Shouldn't be called"); throw new UnsupportedOperationException("Shouldn't be called");
} }
} }

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

@ -14,12 +14,12 @@
* limitations under the License. * limitations under the License.
*/ */
package test.advice; package org.springframework.tests.aop.advice;
import org.springframework.aop.support.DelegatingIntroductionInterceptor; import org.springframework.aop.support.DelegatingIntroductionInterceptor;
import org.springframework.aop.support.DefaultIntroductionAdvisor; import org.springframework.aop.support.DefaultIntroductionAdvisor;
import org.springframework.tests.aop.interceptor.TimestampIntroductionInterceptor;
import test.interceptor.TimestampIntroductionInterceptor;
/** /**
* *

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

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

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

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

7
spring-context/src/test/java/test/interceptor/TimestampIntroductionInterceptor.java → spring-aop/src/test/java/org/springframework/tests/aop/interceptor/TimestampIntroductionInterceptor.java

@ -14,15 +14,14 @@
* limitations under the License. * limitations under the License.
*/ */
package test.interceptor; package org.springframework.tests.aop.interceptor;
import org.springframework.aop.support.DelegatingIntroductionInterceptor; import org.springframework.aop.support.DelegatingIntroductionInterceptor;
import org.springframework.tests.TimeStamped;
import test.util.TimeStamped;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class TimestampIntroductionInterceptor extends DelegatingIntroductionInterceptor public class TimestampIntroductionInterceptor extends DelegatingIntroductionInterceptor
implements TimeStamped { implements TimeStamped {
private long ts; private long ts;

12
spring-webmvc/src/test/java/org/springframework/beans/Person.java → spring-aop/src/test/java/org/springframework/tests/sample/beans/Person.java

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.beans; package org.springframework.tests.sample.beans;
/** /**
* *
@ -23,14 +23,16 @@ package org.springframework.beans;
public interface Person { public interface Person {
String getName(); String getName();
void setName(String name); void setName(String name);
int getAge(); int getAge();
void setAge(int i); void setAge(int i);
/** /**
* Test for non-property method matching. * Test for non-property method matching. If the parameter is a Throwable, it will be
* If the parameter is a Throwable, it will be thrown rather than * thrown rather than returned.
* returned.
*/ */
Object echo(Object o) throws Throwable; Object echo(Object o) throws Throwable;
} }

2
spring-webmvc/src/test/java/org/springframework/beans/SerializablePerson.java → spring-aop/src/test/java/org/springframework/tests/sample/beans/SerializablePerson.java

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

2
spring-aop/src/test/java/test/beans/subpkg/DeepBean.java → spring-aop/src/test/java/org/springframework/tests/sample/beans/subpkg/DeepBean.java

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package test.beans.subpkg; package org.springframework.tests.sample.beans.subpkg;
import org.springframework.aop.aspectj.AspectJExpressionPointcutTests; import org.springframework.aop.aspectj.AspectJExpressionPointcutTests;

2
spring-aop/src/test/java/test/annotation/EmptySpringAnnotation.java

@ -25,4 +25,4 @@ import java.lang.annotation.Target;
@Target(ElementType.TYPE) @Target(ElementType.TYPE)
public @interface EmptySpringAnnotation { public @interface EmptySpringAnnotation {
} }

2
spring-aop/src/test/java/test/aop/Lockable.java

@ -30,4 +30,4 @@ public interface Lockable {
void unlock(); void unlock();
boolean locked(); boolean locked();
} }

70
spring-aop/src/test/java/test/aop/MethodCounter.java

@ -1,70 +0,0 @@
/*
* Copyright 2002-2012 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
*
* http://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 test.aop;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.HashMap;
/**
* Abstract superclass for counting advices etc.
*
* @author Rod Johnson
* @author Chris Beams
*/
@SuppressWarnings("serial")
public class MethodCounter implements Serializable {
/** Method name --> count, does not understand overloading */
private HashMap<String, Integer> map = new HashMap<String, Integer>();
private int allCount;
protected void count(Method m) {
count(m.getName());
}
protected void count(String methodName) {
Integer i = map.get(methodName);
i = (i != null) ? new Integer(i.intValue() + 1) : new Integer(1);
map.put(methodName, i);
++allCount;
}
public int getCalls(String methodName) {
Integer i = map.get(methodName);
return (i != null ? i.intValue() : 0);
}
public int getCalls() {
return allCount;
}
/**
* A bit simplistic: just wants the same class.
* Doesn't worry about counts.
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object other) {
return (other != null && other.getClass() == this.getClass());
}
public int hashCode() {
return getClass().hashCode();
}
}

58
spring-aop/src/test/java/test/aop/NopInterceptor.java

@ -1,58 +0,0 @@
/*
* Copyright 2002-2012 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
*
* http://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 test.aop;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
/**
* Trivial interceptor that can be introduced in a chain to display it.
*
* @author Rod Johnson
*/
public class NopInterceptor implements MethodInterceptor {
private int count;
/**
* @see org.aopalliance.intercept.MethodInterceptor#invoke(MethodInvocation)
*/
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
increment();
return invocation.proceed();
}
public int getCount() {
return this.count;
}
protected void increment() {
++count;
}
public boolean equals(Object other) {
if (!(other instanceof NopInterceptor)) {
return false;
}
if (this == other) {
return true;
}
return this.count == ((NopInterceptor) other).count;
}
}

2
spring-aop/src/test/java/test/aop/PerTargetAspect.java

@ -33,4 +33,4 @@ public class PerTargetAspect implements Ordered {
public void setOrder(int order) { public void setOrder(int order) {
this.order = order; this.order = order;
} }
} }

50
spring-aop/src/test/java/test/aop/SerializableNopInterceptor.java

@ -1,50 +0,0 @@
/*
* Copyright 2002-2012 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
*
* http://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 test.aop;
import java.io.Serializable;
/**
* Subclass of NopInterceptor that is serializable and
* can be used to test proxy serialization.
*
* @author Rod Johnson
* @author Chris Beams
*/
@SuppressWarnings("serial")
public class SerializableNopInterceptor extends NopInterceptor implements Serializable {
/**
* We must override this field and the related methods as
* otherwise count won't be serialized from the non-serializable
* NopInterceptor superclass.
*/
private int count;
@Override
public int getCount() {
return this.count;
}
@Override
protected void increment() {
++count;
}
}

2
spring-aop/src/test/java/test/aop/TwoAdviceAspect.java

@ -34,4 +34,4 @@ public class TwoAdviceAspect {
public void countSet(int newAge) throws Exception { public void countSet(int newAge) throws Exception {
++totalCalls; ++totalCalls;
} }
} }

36
spring-aop/src/test/java/test/beans/Colour.java

@ -1,36 +0,0 @@
/*
* Copyright 2002-2007 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
*
* http://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 test.beans;
import org.springframework.core.enums.ShortCodedLabeledEnum;
/**
* @author Rob Harrop
*/
@SuppressWarnings("serial")
public class Colour extends ShortCodedLabeledEnum {
public static final Colour RED = new Colour(0, "RED");
public static final Colour BLUE = new Colour(1, "BLUE");
public static final Colour GREEN = new Colour(2, "GREEN");
public static final Colour PURPLE = new Colour(3, "PURPLE");
private Colour(int code, String label) {
super(code, label);
}
}

90
spring-aop/src/test/java/test/beans/DerivedTestBean.java

@ -1,90 +0,0 @@
/*
* Copyright 2002-2012 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
*
* http://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 test.beans;
import java.io.Serializable;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.DisposableBean;
/**
* @author Juergen Hoeller
* @since 21.08.2003
*/
@SuppressWarnings("serial")
public class DerivedTestBean extends TestBean implements Serializable, BeanNameAware, DisposableBean {
private String beanName;
private boolean initialized;
private boolean destroyed;
public DerivedTestBean() {
}
public DerivedTestBean(String[] names) {
if (names == null || names.length < 2) {
throw new IllegalArgumentException("Invalid names array");
}
setName(names[0]);
setBeanName(names[1]);
}
public static DerivedTestBean create(String[] names) {
return new DerivedTestBean(names);
}
@Override
public void setBeanName(String beanName) {
if (this.beanName == null || beanName == null) {
this.beanName = beanName;
}
}
@Override
public String getBeanName() {
return beanName;
}
public void setSpouseRef(String name) {
setSpouse(new TestBean(name));
}
public void initialize() {
this.initialized = true;
}
public boolean wasInitialized() {
return initialized;
}
@Override
public void destroy() {
this.destroyed = true;
}
@Override
public boolean wasDestroyed() {
return destroyed;
}
}

23
spring-aop/src/test/java/test/beans/INestedTestBean.java

@ -1,23 +0,0 @@
/*
* Copyright 2002-2012 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
*
* http://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 test.beans;
public interface INestedTestBean {
public String getCompany();
}

24
spring-aop/src/test/java/test/beans/IOther.java

@ -1,24 +0,0 @@
/*
* Copyright 2002-2012 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
*
* http://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 test.beans;
public interface IOther {
void absquatulate();
}

69
spring-aop/src/test/java/test/beans/ITestBean.java

@ -1,69 +0,0 @@
/*
* Copyright 2002-2007 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
*
* http://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 test.beans;
import java.io.IOException;
/**
* Interface used for {@link test.beans.TestBean}.
*
* <p>Two methods are the same as on Person, but if this
* extends person it breaks quite a few tests..
*
* @author Rod Johnson
* @author Juergen Hoeller
*/
public interface ITestBean {
int getAge();
void setAge(int age);
String getName();
void setName(String name);
ITestBean getSpouse();
void setSpouse(ITestBean spouse);
ITestBean[] getSpouses();
String[] getStringArray();
void setStringArray(String[] stringArray);
/**
* Throws a given (non-null) exception.
*/
void exceptional(Throwable t) throws Throwable;
Object returnsThis();
INestedTestBean getDoctor();
INestedTestBean getLawyer();
/**
* Increment the age by one.
* @return the previous age
*/
int haveBirthday();
void unreliableFileOperation() throws IOException;
}

61
spring-aop/src/test/java/test/beans/NestedTestBean.java

@ -1,61 +0,0 @@
/*
* Copyright 2002-2012 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
*
* http://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 test.beans;
/**
* Simple nested test bean used for testing bean factories, AOP framework etc.
*
* @author Trevor D. Cook
* @since 30.09.2003
*/
public class NestedTestBean implements INestedTestBean {
private String company = "";
public NestedTestBean() {
}
public NestedTestBean(String company) {
setCompany(company);
}
public void setCompany(String company) {
this.company = (company != null ? company : "");
}
@Override
public String getCompany() {
return company;
}
public boolean equals(Object obj) {
if (!(obj instanceof NestedTestBean)) {
return false;
}
NestedTestBean ntb = (NestedTestBean) obj;
return this.company.equals(ntb.company);
}
public int hashCode() {
return this.company.hashCode();
}
public String toString() {
return "NestedTestBean: " + this.company;
}
}

431
spring-aop/src/test/java/test/beans/TestBean.java

@ -1,431 +0,0 @@
/*
* Copyright 2002-2012 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
*
* http://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 test.beans;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import org.springframework.util.ObjectUtils;
/**
* Simple test bean used for testing bean factories, the AOP framework etc.
*
* @author Rod Johnson
* @author Juergen Hoeller
* @since 15 April 2001
*/
public class TestBean implements ITestBean, IOther, Comparable<Object> {
private String beanName;
private String country;
private boolean postProcessed;
private String name;
private String sex;
private int age;
private boolean jedi;
private ITestBean[] spouses;
private String touchy;
private String[] stringArray;
private Integer[] someIntegerArray;
private Date date = new Date();
private Float myFloat = new Float(0.0);
private Collection<?> friends = new LinkedList<Object>();
private Set<?> someSet = new HashSet<Object>();
private Map<?, ?> someMap = new HashMap<Object, Object>();
private List<?> someList = new ArrayList<Object>();
private Properties someProperties = new Properties();
private INestedTestBean doctor = new NestedTestBean();
private INestedTestBean lawyer = new NestedTestBean();
private boolean destroyed;
private Number someNumber;
private Colour favouriteColour;
private Boolean someBoolean;
private List<?> otherColours;
private List<?> pets;
public TestBean() {
}
public TestBean(String name) {
this.name = name;
}
public TestBean(ITestBean spouse) {
this.spouses = new ITestBean[] {spouse};
}
public TestBean(String name, int age) {
this.name = name;
this.age = age;
}
public TestBean(ITestBean spouse, Properties someProperties) {
this.spouses = new ITestBean[] {spouse};
this.someProperties = someProperties;
}
public TestBean(List<?> someList) {
this.someList = someList;
}
public TestBean(Set<?> someSet) {
this.someSet = someSet;
}
public TestBean(Map<?, ?> someMap) {
this.someMap = someMap;
}
public TestBean(Properties someProperties) {
this.someProperties = someProperties;
}
public void setBeanName(String beanName) {
this.beanName = beanName;
}
public String getBeanName() {
return beanName;
}
public void setPostProcessed(boolean postProcessed) {
this.postProcessed = postProcessed;
}
public boolean isPostProcessed() {
return postProcessed;
}
@Override
public String getName() {
return name;
}
@Override
public void setName(String name) {
this.name = name;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
if (this.name == null) {
this.name = sex;
}
}
@Override
public int getAge() {
return age;
}
@Override
public void setAge(int age) {
this.age = age;
}
public boolean isJedi() {
return jedi;
}
public void setJedi(boolean jedi) {
this.jedi = jedi;
}
@Override
public ITestBean getSpouse() {
return (spouses != null ? spouses[0] : null);
}
@Override
public void setSpouse(ITestBean spouse) {
this.spouses = new ITestBean[] {spouse};
}
@Override
public ITestBean[] getSpouses() {
return spouses;
}
public String getTouchy() {
return touchy;
}
public void setTouchy(String touchy) throws Exception {
if (touchy.indexOf('.') != -1) {
throw new Exception("Can't contain a .");
}
if (touchy.indexOf(',') != -1) {
throw new NumberFormatException("Number format exception: contains a ,");
}
this.touchy = touchy;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
@Override
public String[] getStringArray() {
return stringArray;
}
@Override
public void setStringArray(String[] stringArray) {
this.stringArray = stringArray;
}
public Integer[] getSomeIntegerArray() {
return someIntegerArray;
}
public void setSomeIntegerArray(Integer[] someIntegerArray) {
this.someIntegerArray = someIntegerArray;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public Float getMyFloat() {
return myFloat;
}
public void setMyFloat(Float myFloat) {
this.myFloat = myFloat;
}
public Collection<?> getFriends() {
return friends;
}
public void setFriends(Collection<?> friends) {
this.friends = friends;
}
public Set<?> getSomeSet() {
return someSet;
}
public void setSomeSet(Set<?> someSet) {
this.someSet = someSet;
}
public Map<?, ?> getSomeMap() {
return someMap;
}
public void setSomeMap(Map<?, ?> someMap) {
this.someMap = someMap;
}
public List<?> getSomeList() {
return someList;
}
public void setSomeList(List<?> someList) {
this.someList = someList;
}
public Properties getSomeProperties() {
return someProperties;
}
public void setSomeProperties(Properties someProperties) {
this.someProperties = someProperties;
}
@Override
public INestedTestBean getDoctor() {
return doctor;
}
public void setDoctor(INestedTestBean doctor) {
this.doctor = doctor;
}
@Override
public INestedTestBean getLawyer() {
return lawyer;
}
public void setLawyer(INestedTestBean lawyer) {
this.lawyer = lawyer;
}
public Number getSomeNumber() {
return someNumber;
}
public void setSomeNumber(Number someNumber) {
this.someNumber = someNumber;
}
public Colour getFavouriteColour() {
return favouriteColour;
}
public void setFavouriteColour(Colour favouriteColour) {
this.favouriteColour = favouriteColour;
}
public Boolean getSomeBoolean() {
return someBoolean;
}
public void setSomeBoolean(Boolean someBoolean) {
this.someBoolean = someBoolean;
}
public List<?> getOtherColours() {
return otherColours;
}
public void setOtherColours(List<?> otherColours) {
this.otherColours = otherColours;
}
public List<?> getPets() {
return pets;
}
public void setPets(List<?> pets) {
this.pets = pets;
}
/**
* @see ITestBean#exceptional(Throwable)
*/
@Override
public void exceptional(Throwable t) throws Throwable {
if (t != null) {
throw t;
}
}
@Override
public void unreliableFileOperation() throws IOException {
throw new IOException();
}
/**
* @see ITestBean#returnsThis()
*/
@Override
public Object returnsThis() {
return this;
}
/**
* @see IOther#absquatulate()
*/
@Override
public void absquatulate() {
}
@Override
public int haveBirthday() {
return age++;
}
public void destroy() {
this.destroyed = true;
}
public boolean wasDestroyed() {
return destroyed;
}
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (other == null || !(other instanceof TestBean)) {
return false;
}
TestBean tb2 = (TestBean) other;
return (ObjectUtils.nullSafeEquals(this.name, tb2.name) && this.age == tb2.age);
}
public int hashCode() {
return this.age;
}
@Override
public int compareTo(Object other) {
if (this.name != null && other instanceof TestBean) {
return this.name.compareTo(((TestBean) other).getName());
}
else {
return 1;
}
}
public String toString() {
return this.name;
}
}

97
spring-aop/src/test/java/test/parsing/CollectingReaderEventListener.java

@ -1,97 +0,0 @@
/*
* Copyright 2002-2012 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
*
* http://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 test.parsing;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.parsing.AliasDefinition;
import org.springframework.beans.factory.parsing.ComponentDefinition;
import org.springframework.beans.factory.parsing.DefaultsDefinition;
import org.springframework.beans.factory.parsing.ImportDefinition;
import org.springframework.beans.factory.parsing.ReaderEventListener;
/**
* @author Rob Harrop
* @author Juergen Hoeller
* @author Chris Beams
*/
public class CollectingReaderEventListener implements ReaderEventListener {
private final List<DefaultsDefinition> defaults = new LinkedList<DefaultsDefinition>();
private final Map<String, Object> componentDefinitions = new LinkedHashMap<String, Object>(8);
private final Map<String, Object> aliasMap = new LinkedHashMap<String, Object>(8);
private final List<ImportDefinition> imports = new LinkedList<ImportDefinition>();
@Override
public void defaultsRegistered(DefaultsDefinition defaultsDefinition) {
this.defaults.add(defaultsDefinition);
}
public List<DefaultsDefinition> getDefaults() {
return Collections.unmodifiableList(this.defaults);
}
@Override
public void componentRegistered(ComponentDefinition componentDefinition) {
this.componentDefinitions.put(componentDefinition.getName(), componentDefinition);
}
public ComponentDefinition getComponentDefinition(String name) {
return (ComponentDefinition) this.componentDefinitions.get(name);
}
public ComponentDefinition[] getComponentDefinitions() {
Collection<Object> collection = this.componentDefinitions.values();
return collection.toArray(new ComponentDefinition[collection.size()]);
}
@Override
@SuppressWarnings("unchecked")
public void aliasRegistered(AliasDefinition aliasDefinition) {
List aliases = (List) this.aliasMap.get(aliasDefinition.getBeanName());
if(aliases == null) {
aliases = new ArrayList();
this.aliasMap.put(aliasDefinition.getBeanName(), aliases);
}
aliases.add(aliasDefinition);
}
public List<?> getAliases(String beanName) {
List<?> aliases = (List<?>) this.aliasMap.get(beanName);
return aliases == null ? null : Collections.unmodifiableList(aliases);
}
@Override
public void importProcessed(ImportDefinition importDefinition) {
this.imports.add(importDefinition);
}
public List<ImportDefinition> getImports() {
return Collections.unmodifiableList(this.imports);
}
}

100
spring-aop/src/test/java/test/util/SerializationTestUtils.java

@ -1,100 +0,0 @@
/*
* Copyright 2002-2012 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
*
* http://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 test.util;
import java.awt.*;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.NotSerializableException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.Serializable;
import static org.junit.Assert.*;
import org.junit.Test;
import test.beans.TestBean;
/**
* Utilities for testing serializability of objects.
* Exposes static methods for use in other test cases.
* Contains {@link org.junit.Test} methods to test itself.
*
* @author Rod Johnson
* @author Chris Beams
*/
public final class SerializationTestUtils {
public static void testSerialization(Object o) throws IOException {
OutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(o);
}
public static boolean isSerializable(Object o) throws IOException {
try {
testSerialization(o);
return true;
}
catch (NotSerializableException ex) {
return false;
}
}
public static Object serializeAndDeserialize(Object o) throws IOException, ClassNotFoundException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(o);
oos.flush();
baos.flush();
byte[] bytes = baos.toByteArray();
ByteArrayInputStream is = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(is);
Object o2 = ois.readObject();
return o2;
}
@Test(expected=NotSerializableException.class)
public void testWithNonSerializableObject() throws IOException {
TestBean o = new TestBean();
assertFalse(o instanceof Serializable);
assertFalse(isSerializable(o));
testSerialization(o);
}
@Test
public void testWithSerializableObject() throws Exception {
int x = 5;
int y = 10;
Point p = new Point(x, y);
assertTrue(p instanceof Serializable);
testSerialization(p);
assertTrue(isSerializable(p));
Point p2 = (Point) serializeAndDeserialize(p);
assertNotSame(p, p2);
assertEquals(x, (int) p2.getX());
assertEquals(y, (int) p2.getY());
}
}

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

Loading…
Cancel
Save