Merge branch '3.2.x' into cleanup-3.2.x
This commit is contained in:
		
						commit
						1c31f6af8e
					
				| 
						 | 
				
			
			@ -13,12 +13,15 @@ jmx.log
 | 
			
		|||
derby.log
 | 
			
		||||
spring-test/test-output/
 | 
			
		||||
.gradle
 | 
			
		||||
build
 | 
			
		||||
.classpath
 | 
			
		||||
.project
 | 
			
		||||
argfile*
 | 
			
		||||
pom.xml
 | 
			
		||||
 | 
			
		||||
/build
 | 
			
		||||
buildSrc/build
 | 
			
		||||
/spring-*/build
 | 
			
		||||
 | 
			
		||||
# IDEA artifacts and output dirs
 | 
			
		||||
*.iml
 | 
			
		||||
*.ipr
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -23,7 +23,7 @@ truly trivial, e.g. typo fixes, removing compiler warnings, etc.
 | 
			
		|||
 | 
			
		||||
If you're considering anything more than correcting a typo or fixing a minor
 | 
			
		||||
bug, please discuss it on the [spring-framework-contrib][] mailing list before
 | 
			
		||||
submitting a pull request. We're happy to provide guidance but please spend an
 | 
			
		||||
submitting a pull request. We're happy to provide guidance, but please spend an
 | 
			
		||||
hour or two researching the subject on your own including searching the mailing
 | 
			
		||||
list for prior discussions.
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -31,26 +31,26 @@ list for prior discussions.
 | 
			
		|||
 | 
			
		||||
If you have not previously done so, please fill out and submit the
 | 
			
		||||
[SpringSource CLA form][]. You'll receive a token when this process is complete.
 | 
			
		||||
Keep track of this, you may be asked for it later!
 | 
			
		||||
Keep track of this; you may be asked for it later!
 | 
			
		||||
 | 
			
		||||
Note that emailing/postal mailing a signed copy is _not_ necessary. Submission
 | 
			
		||||
of the web form is all that is required.
 | 
			
		||||
 | 
			
		||||
When you've completed the web form, simply add the following in a comment on
 | 
			
		||||
Once you've completed the web form, simply add the following in a comment on
 | 
			
		||||
your pull request:
 | 
			
		||||
 | 
			
		||||
    I have signed and agree to the terms of the SpringSource Individual
 | 
			
		||||
    Contributor License Agreement.
 | 
			
		||||
 | 
			
		||||
You do not need to include your token/id. Please add the statement above to all
 | 
			
		||||
future pull requests as well, simply so the Spring Framework team knows
 | 
			
		||||
future pull requests as well, simply so that the Spring Framework team knows
 | 
			
		||||
immediately that this process is complete.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
## Create your branch from `3.2.x`
 | 
			
		||||
 | 
			
		||||
If your pull request addresses a bug or improvement, please create your branch
 | 
			
		||||
Spring Framework's `3.2.x` branch. `master` is reserved for work on new features
 | 
			
		||||
from Spring Framework's `3.2.x` branch. `master` is reserved for work on new features
 | 
			
		||||
for the next major version of the framework. Rest assured that if your pull
 | 
			
		||||
request is accepted and merged into `3.2.x`, these changes will also eventually
 | 
			
		||||
be merged into `master`.
 | 
			
		||||
| 
						 | 
				
			
			@ -72,7 +72,7 @@ Please carefully follow the whitespace and formatting conventions already
 | 
			
		|||
present in the framework.
 | 
			
		||||
 | 
			
		||||
1. Tabs, not spaces
 | 
			
		||||
1. Unix (LF), not dos (CRLF) line endings
 | 
			
		||||
1. Unix (LF), not DOS (CRLF) line endings
 | 
			
		||||
1. Eliminate all trailing whitespace
 | 
			
		||||
1. Wrap Javadoc at 90 characters
 | 
			
		||||
1. Aim to wrap code at 90 characters, but favor readability over wrapping
 | 
			
		||||
| 
						 | 
				
			
			@ -228,11 +228,11 @@ Most importantly, please format your commit messages in the following way
 | 
			
		|||
 | 
			
		||||
1. Use imperative statements in the subject line, e.g. "Fix broken Javadoc link"
 | 
			
		||||
1. Begin the subject line sentence with a capitalized verb, e.g. "Add, Prune,
 | 
			
		||||
   Fix, Introduce, Avoid, etc"
 | 
			
		||||
   Fix, Introduce, Avoid, etc."
 | 
			
		||||
1. Do not end the subject line with a period
 | 
			
		||||
1. Keep the subject line to 50 characters or less if possible
 | 
			
		||||
1. Wrap lines in the body at 72 characters or less
 | 
			
		||||
1. Mention associated jira issue(s) at the end of the commit comment, prefixed
 | 
			
		||||
1. Mention associated JIRA issue(s) at the end of the commit comment, prefixed
 | 
			
		||||
   with "Issue: " as above
 | 
			
		||||
1. In the body of the commit message, explain how things worked before this
 | 
			
		||||
   commit, what has changed, and how things work now
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										40
									
								
								build.gradle
								
								
								
								
							
							
						
						
									
										40
									
								
								build.gradle
								
								
								
								
							| 
						 | 
				
			
			@ -28,6 +28,7 @@ configure(allprojects) {
 | 
			
		|||
	apply plugin: "java"
 | 
			
		||||
	apply plugin: "propdeps-eclipse"
 | 
			
		||||
	apply plugin: "propdeps-idea"
 | 
			
		||||
	apply plugin: "test-source-set-dependencies"
 | 
			
		||||
	apply from: "${gradleScriptDir}/ide.gradle"
 | 
			
		||||
 | 
			
		||||
	group = "org.springframework"
 | 
			
		||||
| 
						 | 
				
			
			@ -110,7 +111,7 @@ configure(allprojects.findAll{it.name in ["spring", "spring-jms", "spring-orm",
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
configure(subprojects - project(":spring-build-junit")) { subproject ->
 | 
			
		||||
configure(subprojects - project(":spring-build-src")) { subproject ->
 | 
			
		||||
	apply plugin: "merge"
 | 
			
		||||
	apply from: "${gradleScriptDir}/publish-maven.gradle"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -159,35 +160,26 @@ configure(subprojects - project(":spring-build-junit")) { subproject ->
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
configure(allprojects - project(":spring-build-junit")) {
 | 
			
		||||
configure(allprojects) {
 | 
			
		||||
	dependencies {
 | 
			
		||||
		testCompile(project(":spring-build-junit"))
 | 
			
		||||
		testCompile("junit:junit:${junitVersion}")
 | 
			
		||||
		testCompile("org.hamcrest:hamcrest-all:1.3")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	eclipse.classpath.file.whenMerged { classpath ->
 | 
			
		||||
		classpath.entries.find{it.path == "/spring-build-junit"}.exported = false
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	test.systemProperties.put("testGroups", properties.get("testGroups"))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
project("spring-build-junit") {
 | 
			
		||||
	description = "Build-time JUnit dependencies and utilities"
 | 
			
		||||
 | 
			
		||||
	// NOTE: This is an internal project and is not published.
 | 
			
		||||
project("spring-build-src") {
 | 
			
		||||
	description = "Exposes gradle buildSrc for IDE support"
 | 
			
		||||
	apply plugin: "groovy"
 | 
			
		||||
 | 
			
		||||
	dependencies {
 | 
			
		||||
		compile("commons-logging:commons-logging:1.1.1")
 | 
			
		||||
		compile("junit:junit:${junitVersion}")
 | 
			
		||||
		compile("org.hamcrest:hamcrest-all:1.3")
 | 
			
		||||
		compile("org.easymock:easymock:${easymockVersion}")
 | 
			
		||||
		compile gradleApi()
 | 
			
		||||
		groovy localGroovy()
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Don't actually generate any artifacts
 | 
			
		||||
	configurations.archives.artifacts.clear()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
project("spring-core") {
 | 
			
		||||
	description = "Spring Core"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -258,7 +250,7 @@ project("spring-core") {
 | 
			
		|||
		optional("org.aspectj:aspectjweaver:${aspectjVersion}")
 | 
			
		||||
		optional("net.sf.jopt-simple:jopt-simple:3.0")
 | 
			
		||||
		optional("log4j:log4j:1.2.17")
 | 
			
		||||
		testCompile("xmlunit:xmlunit:1.2")
 | 
			
		||||
		testCompile("xmlunit:xmlunit:1.3")
 | 
			
		||||
		testCompile("org.codehaus.woodstox:wstx-asl:3.2.7")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -395,7 +387,7 @@ project("spring-oxm") {
 | 
			
		|||
		optional("org.apache.xmlbeans:xmlbeans:2.4.0")
 | 
			
		||||
		optional("org.codehaus.castor:castor-xml:1.3.2")
 | 
			
		||||
		testCompile("org.codehaus.jettison:jettison:1.0.1")
 | 
			
		||||
		testCompile("xmlunit:xmlunit:1.2")
 | 
			
		||||
		testCompile("xmlunit:xmlunit:1.3")
 | 
			
		||||
		testCompile("xmlpull:xmlpull:1.1.3.4a")
 | 
			
		||||
		testCompile(files(genCastor.classesDir).builtBy(genCastor))
 | 
			
		||||
		testCompile(files(genJaxb.classesDir).builtBy(genJaxb))
 | 
			
		||||
| 
						 | 
				
			
			@ -500,7 +492,7 @@ project("spring-web") {
 | 
			
		|||
		}
 | 
			
		||||
		optional("log4j:log4j:1.2.17")
 | 
			
		||||
		testCompile(project(":spring-context-support"))  // for JafMediaTypeFactory
 | 
			
		||||
		testCompile("xmlunit:xmlunit:1.2")
 | 
			
		||||
		testCompile("xmlunit:xmlunit:1.3")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// pick up ContextLoader.properties in src/main
 | 
			
		||||
| 
						 | 
				
			
			@ -536,7 +528,6 @@ project("spring-orm") {
 | 
			
		|||
		testCompile("org.eclipse.persistence:org.eclipse.persistence.asm:1.0.1")
 | 
			
		||||
		testCompile("org.eclipse.persistence:org.eclipse.persistence.antlr:1.0.1")
 | 
			
		||||
		testCompile("hsqldb:hsqldb:${hsqldbVersion}")
 | 
			
		||||
		testCompile(project(":spring-web").sourceSets.test.output)
 | 
			
		||||
		compile(project(":spring-core"))
 | 
			
		||||
		compile(project(":spring-beans"))
 | 
			
		||||
		optional(project(":spring-aop"))
 | 
			
		||||
| 
						 | 
				
			
			@ -592,7 +583,7 @@ project("spring-webmvc") {
 | 
			
		|||
		testCompile(project(":spring-aop"))
 | 
			
		||||
		testCompile("org.slf4j:slf4j-jcl:${slf4jVersion}")
 | 
			
		||||
		testCompile("rhino:js:1.7R1")
 | 
			
		||||
		testCompile("xmlunit:xmlunit:1.2")
 | 
			
		||||
		testCompile("xmlunit:xmlunit:1.3")
 | 
			
		||||
		testCompile("dom4j:dom4j:1.6.1") {
 | 
			
		||||
			exclude group: "xml-apis", module: "xml-apis"
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -701,7 +692,7 @@ project("spring-test-mvc") {
 | 
			
		|||
		provided("javax.servlet:javax.servlet-api:3.0.1")
 | 
			
		||||
		optional("org.hamcrest:hamcrest-core:1.3")
 | 
			
		||||
		optional("com.jayway.jsonpath:json-path:0.8.1")
 | 
			
		||||
		optional("xmlunit:xmlunit:1.2")
 | 
			
		||||
		optional("xmlunit:xmlunit:1.3")
 | 
			
		||||
		testCompile("org.slf4j:slf4j-jcl:${slf4jVersion}")
 | 
			
		||||
		testCompile("javax.servlet:jstl:1.2")
 | 
			
		||||
		testCompile("org.hibernate:hibernate-validator:4.3.0.Final")
 | 
			
		||||
| 
						 | 
				
			
			@ -786,6 +777,7 @@ configure(rootProject) {
 | 
			
		|||
 | 
			
		||||
	dependencies { // for integration tests
 | 
			
		||||
		testCompile(project(":spring-core"))
 | 
			
		||||
		testCompile(project(":spring-core").sourceSets.test.output)
 | 
			
		||||
		testCompile(project(":spring-beans"))
 | 
			
		||||
		testCompile(project(":spring-aop"))
 | 
			
		||||
		testCompile(project(":spring-expression"))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,7 +14,7 @@
 | 
			
		|||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package org.springframework.build.gradle.merge
 | 
			
		||||
package org.springframework.build.gradle
 | 
			
		||||
 | 
			
		||||
import org.gradle.api.*
 | 
			
		||||
import org.gradle.api.artifacts.Configuration
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,57 @@
 | 
			
		|||
/*
 | 
			
		||||
 * 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.Plugin
 | 
			
		||||
import org.gradle.api.Project
 | 
			
		||||
import org.gradle.api.artifacts.Configuration;
 | 
			
		||||
import org.gradle.api.artifacts.ProjectDependency;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Gradle plugin that automatically updates testCompile dependencies to include
 | 
			
		||||
 * the test source sets of project dependencies.
 | 
			
		||||
 *
 | 
			
		||||
 * @author Phillip Webb
 | 
			
		||||
 */
 | 
			
		||||
class TestSourceSetDependenciesPlugin implements Plugin<Project> {
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public void apply(Project project) {
 | 
			
		||||
		project.afterEvaluate {
 | 
			
		||||
			Set<ProjectDependency> projectDependencies = new LinkedHashSet<>()
 | 
			
		||||
			collectProjectDependencies(projectDependencies, project)
 | 
			
		||||
			projectDependencies.each {
 | 
			
		||||
				project.dependencies.add("testCompile", it.dependencyProject.sourceSets.test.output)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private void collectProjectDependencies(Set<ProjectDependency> projectDependencies,
 | 
			
		||||
			Project project) {
 | 
			
		||||
		for(def configurationName in ["compile", "optional", "provided"]) {
 | 
			
		||||
			Configuration configuration = project.getConfigurations().findByName(configurationName)
 | 
			
		||||
			if(configuration) {
 | 
			
		||||
				configuration.dependencies.findAll { it instanceof ProjectDependency }.each {
 | 
			
		||||
					projectDependencies.add(it)
 | 
			
		||||
					collectProjectDependencies(projectDependencies, it.dependencyProject)
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1 +1 @@
 | 
			
		|||
implementation-class=org.springframework.build.gradle.merge.MergePlugin
 | 
			
		||||
implementation-class=org.springframework.build.gradle.MergePlugin
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
implementation-class=org.springframework.build.gradle.TestSourceSetDependenciesPlugin
 | 
			
		||||
| 
						 | 
				
			
			@ -22,4 +22,7 @@ include "spring-web"
 | 
			
		|||
include "spring-webmvc"
 | 
			
		||||
include "spring-webmvc-portlet"
 | 
			
		||||
include "spring-webmvc-tiles3"
 | 
			
		||||
include "spring-build-junit"
 | 
			
		||||
 | 
			
		||||
// Exposes gradle buildSrc for IDE support
 | 
			
		||||
include "buildSrc"
 | 
			
		||||
rootProject.children.find{ it.name == "buildSrc" }.name = "spring-build-src"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,13 +16,15 @@
 | 
			
		|||
 | 
			
		||||
package org.springframework.aop.config;
 | 
			
		||||
 | 
			
		||||
import static org.junit.Assert.*;
 | 
			
		||||
import static org.junit.Assert.assertTrue;
 | 
			
		||||
import static org.junit.Assert.fail;
 | 
			
		||||
import static test.util.TestResourceUtils.qualifiedResource;
 | 
			
		||||
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
 | 
			
		||||
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Mark Fisher
 | 
			
		||||
| 
						 | 
				
			
			@ -33,7 +35,9 @@ public final class AopNamespaceHandlerPointcutErrorTests {
 | 
			
		|||
	@Test
 | 
			
		||||
	public void testDuplicatePointcutConfig() {
 | 
			
		||||
		try {
 | 
			
		||||
			new XmlBeanFactory(qualifiedResource(getClass(), "pointcutDuplication.xml"));
 | 
			
		||||
			DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
			new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
 | 
			
		||||
					qualifiedResource(getClass(), "pointcutDuplication.xml"));
 | 
			
		||||
			fail("parsing should have caused a BeanDefinitionStoreException");
 | 
			
		||||
		}
 | 
			
		||||
		catch (BeanDefinitionStoreException ex) {
 | 
			
		||||
| 
						 | 
				
			
			@ -44,7 +48,9 @@ public final class AopNamespaceHandlerPointcutErrorTests {
 | 
			
		|||
	@Test
 | 
			
		||||
	public void testMissingPointcutConfig() {
 | 
			
		||||
		try {
 | 
			
		||||
			new XmlBeanFactory(qualifiedResource(getClass(), "pointcutMissing.xml"));
 | 
			
		||||
			DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
			new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
 | 
			
		||||
					qualifiedResource(getClass(), "pointcutMissing.xml"));
 | 
			
		||||
			fail("parsing should have caused a BeanDefinitionStoreException");
 | 
			
		||||
		}
 | 
			
		||||
		catch (BeanDefinitionStoreException ex) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,7 +22,8 @@ import static test.util.TestResourceUtils.qualifiedResource;
 | 
			
		|||
import org.aopalliance.intercept.MethodInterceptor;
 | 
			
		||||
import org.aopalliance.intercept.MethodInvocation;
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 | 
			
		||||
import org.springframework.core.io.Resource;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			@ -37,12 +38,13 @@ public final class PrototypeTargetTests {
 | 
			
		|||
	@Test
 | 
			
		||||
	public void testPrototypeProxyWithPrototypeTarget() {
 | 
			
		||||
		TestBeanImpl.constructionCount = 0;
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
 | 
			
		||||
		for (int i = 0; i < 10; i++) {
 | 
			
		||||
			TestBean tb = (TestBean) xbf.getBean("testBeanPrototype");
 | 
			
		||||
			TestBean tb = (TestBean) bf.getBean("testBeanPrototype");
 | 
			
		||||
			tb.doSomething();
 | 
			
		||||
		}
 | 
			
		||||
		TestInterceptor interceptor = (TestInterceptor) xbf.getBean("testInterceptor");
 | 
			
		||||
		TestInterceptor interceptor = (TestInterceptor) bf.getBean("testInterceptor");
 | 
			
		||||
		assertEquals(10, TestBeanImpl.constructionCount);
 | 
			
		||||
		assertEquals(10, interceptor.invocationCount);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -50,12 +52,13 @@ public final class PrototypeTargetTests {
 | 
			
		|||
	@Test
 | 
			
		||||
	public void testSingletonProxyWithPrototypeTarget() {
 | 
			
		||||
		TestBeanImpl.constructionCount = 0;
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
 | 
			
		||||
		for (int i = 0; i < 10; i++) {
 | 
			
		||||
			TestBean tb = (TestBean) xbf.getBean("testBeanSingleton");
 | 
			
		||||
			TestBean tb = (TestBean) bf.getBean("testBeanSingleton");
 | 
			
		||||
			tb.doSomething();
 | 
			
		||||
		}
 | 
			
		||||
		TestInterceptor interceptor = (TestInterceptor) xbf.getBean("testInterceptor");
 | 
			
		||||
		TestInterceptor interceptor = (TestInterceptor) bf.getBean("testInterceptor");
 | 
			
		||||
		assertEquals(1, TestBeanImpl.constructionCount);
 | 
			
		||||
		assertEquals(10, interceptor.invocationCount);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,12 +16,14 @@
 | 
			
		|||
 | 
			
		||||
package org.springframework.aop.interceptor;
 | 
			
		||||
 | 
			
		||||
import static org.junit.Assert.*;
 | 
			
		||||
import static org.junit.Assert.assertEquals;
 | 
			
		||||
import static org.junit.Assert.assertTrue;
 | 
			
		||||
import static test.util.TestResourceUtils.qualifiedResource;
 | 
			
		||||
 | 
			
		||||
import org.aopalliance.intercept.MethodInvocation;
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 | 
			
		||||
import org.springframework.core.io.Resource;
 | 
			
		||||
 | 
			
		||||
import test.beans.ITestBean;
 | 
			
		||||
| 
						 | 
				
			
			@ -40,7 +42,8 @@ public final class ExposeInvocationInterceptorTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testXmlConfig() {
 | 
			
		||||
		XmlBeanFactory bf = new XmlBeanFactory(CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
 | 
			
		||||
		ITestBean tb = (ITestBean) bf.getBean("proxy");
 | 
			
		||||
		String name= "tony";
 | 
			
		||||
		tb.setName(name);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,7 +20,8 @@ import static org.junit.Assert.assertSame;
 | 
			
		|||
import static test.util.TestResourceUtils.qualifiedResource;
 | 
			
		||||
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 | 
			
		||||
import org.springframework.core.io.Resource;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			@ -36,7 +37,8 @@ public final class ScopedProxyAutowireTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testScopedProxyInheritsAutowireCandidateFalse() {
 | 
			
		||||
		XmlBeanFactory bf = new XmlBeanFactory(SCOPED_AUTOWIRE_FALSE_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(SCOPED_AUTOWIRE_FALSE_CONTEXT);
 | 
			
		||||
		TestBean autowired = (TestBean) bf.getBean("autowired");
 | 
			
		||||
		TestBean unscoped = (TestBean) bf.getBean("unscoped");
 | 
			
		||||
		assertSame(unscoped, autowired.getChild());
 | 
			
		||||
| 
						 | 
				
			
			@ -44,7 +46,8 @@ public final class ScopedProxyAutowireTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testScopedProxyReplacesAutowireCandidateTrue() {
 | 
			
		||||
		XmlBeanFactory bf = new XmlBeanFactory(SCOPED_AUTOWIRE_TRUE_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(SCOPED_AUTOWIRE_TRUE_CONTEXT);
 | 
			
		||||
		TestBean autowired = (TestBean) bf.getBean("autowired");
 | 
			
		||||
		TestBean scoped = (TestBean) bf.getBean("scoped");
 | 
			
		||||
		assertSame(scoped, autowired.getChild());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,8 +21,8 @@ import static test.util.TestResourceUtils.qualifiedResource;
 | 
			
		|||
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import org.springframework.aop.framework.Advised;
 | 
			
		||||
import org.springframework.beans.factory.BeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 | 
			
		||||
import org.springframework.core.io.Resource;
 | 
			
		||||
 | 
			
		||||
import test.aop.NopInterceptor;
 | 
			
		||||
| 
						 | 
				
			
			@ -43,7 +43,8 @@ public final class RegexpMethodPointcutAdvisorIntegrationTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testSinglePattern() throws Throwable {
 | 
			
		||||
		BeanFactory bf = new XmlBeanFactory(CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
 | 
			
		||||
		ITestBean advised = (ITestBean) bf.getBean("settersAdvised");
 | 
			
		||||
		// Interceptor behind regexp advisor
 | 
			
		||||
		NopInterceptor nop = (NopInterceptor) bf.getBean("nopInterceptor");
 | 
			
		||||
| 
						 | 
				
			
			@ -61,7 +62,8 @@ public final class RegexpMethodPointcutAdvisorIntegrationTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testMultiplePatterns() throws Throwable {
 | 
			
		||||
		BeanFactory bf = new XmlBeanFactory(CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
 | 
			
		||||
		// This is a CGLIB proxy, so we can proxy it to the target class
 | 
			
		||||
		TestBean advised = (TestBean) bf.getBean("settersAndAbsquatulateAdvised");
 | 
			
		||||
		// Interceptor behind regexp advisor
 | 
			
		||||
| 
						 | 
				
			
			@ -84,7 +86,8 @@ public final class RegexpMethodPointcutAdvisorIntegrationTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testSerialization() throws Throwable {
 | 
			
		||||
		BeanFactory bf = new XmlBeanFactory(CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
 | 
			
		||||
		// This is a CGLIB proxy, so we can proxy it to the target class
 | 
			
		||||
		Person p = (Person) bf.getBean("serializableSettersAdvised");
 | 
			
		||||
		// Interceptor behind regexp advisor
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,7 +16,9 @@
 | 
			
		|||
 | 
			
		||||
package org.springframework.aop.target;
 | 
			
		||||
 | 
			
		||||
import static org.junit.Assert.*;
 | 
			
		||||
import static org.junit.Assert.assertEquals;
 | 
			
		||||
import static org.junit.Assert.assertTrue;
 | 
			
		||||
import static org.junit.Assert.fail;
 | 
			
		||||
import static test.util.TestResourceUtils.qualifiedResource;
 | 
			
		||||
 | 
			
		||||
import org.junit.After;
 | 
			
		||||
| 
						 | 
				
			
			@ -25,7 +27,8 @@ import org.junit.Test;
 | 
			
		|||
import org.springframework.aop.framework.Advised;
 | 
			
		||||
import org.springframework.aop.framework.ProxyFactory;
 | 
			
		||||
import org.springframework.aop.support.DefaultPointcutAdvisor;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 | 
			
		||||
import org.springframework.core.io.Resource;
 | 
			
		||||
 | 
			
		||||
import test.aop.SerializableNopInterceptor;
 | 
			
		||||
| 
						 | 
				
			
			@ -46,11 +49,12 @@ public final class HotSwappableTargetSourceTests {
 | 
			
		|||
	/** Initial count value set in bean factory XML */
 | 
			
		||||
	private static final int INITIAL_COUNT = 10;
 | 
			
		||||
 | 
			
		||||
	private XmlBeanFactory beanFactory;
 | 
			
		||||
	private DefaultListableBeanFactory beanFactory;
 | 
			
		||||
 | 
			
		||||
	@Before
 | 
			
		||||
	public void setUp() throws Exception {
 | 
			
		||||
		this.beanFactory = new XmlBeanFactory(CONTEXT);
 | 
			
		||||
		this.beanFactory = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(CONTEXT);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,13 +16,16 @@
 | 
			
		|||
 | 
			
		||||
package org.springframework.aop.target;
 | 
			
		||||
 | 
			
		||||
import static org.junit.Assert.*;
 | 
			
		||||
import static org.junit.Assert.assertEquals;
 | 
			
		||||
import static org.junit.Assert.assertFalse;
 | 
			
		||||
import static org.junit.Assert.assertTrue;
 | 
			
		||||
import static test.util.TestResourceUtils.qualifiedResource;
 | 
			
		||||
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 | 
			
		||||
import org.springframework.core.io.Resource;
 | 
			
		||||
 | 
			
		||||
import test.beans.ITestBean;
 | 
			
		||||
| 
						 | 
				
			
			@ -43,7 +46,8 @@ public final class LazyInitTargetSourceTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testLazyInitSingletonTargetSource() {
 | 
			
		||||
		XmlBeanFactory bf = new XmlBeanFactory(SINGLETON_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(SINGLETON_CONTEXT);
 | 
			
		||||
		bf.preInstantiateSingletons();
 | 
			
		||||
 | 
			
		||||
		ITestBean tb = (ITestBean) bf.getBean("proxy");
 | 
			
		||||
| 
						 | 
				
			
			@ -54,7 +58,8 @@ public final class LazyInitTargetSourceTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testCustomLazyInitSingletonTargetSource() {
 | 
			
		||||
		XmlBeanFactory bf = new XmlBeanFactory(CUSTOM_TARGET_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CUSTOM_TARGET_CONTEXT);
 | 
			
		||||
		bf.preInstantiateSingletons();
 | 
			
		||||
 | 
			
		||||
		ITestBean tb = (ITestBean) bf.getBean("proxy");
 | 
			
		||||
| 
						 | 
				
			
			@ -65,7 +70,8 @@ public final class LazyInitTargetSourceTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testLazyInitFactoryBeanTargetSource() {
 | 
			
		||||
		XmlBeanFactory bf = new XmlBeanFactory(FACTORY_BEAN_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(FACTORY_BEAN_CONTEXT);
 | 
			
		||||
		bf.preInstantiateSingletons();
 | 
			
		||||
 | 
			
		||||
		Set<?> set1 = (Set<?>) bf.getBean("proxy1");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -41,10 +41,12 @@ public final class PrototypeBasedTargetSourceTests {
 | 
			
		|||
	public void testSerializability() throws Exception {
 | 
			
		||||
		MutablePropertyValues tsPvs = new MutablePropertyValues();
 | 
			
		||||
		tsPvs.add("targetBeanName", "person");
 | 
			
		||||
		RootBeanDefinition tsBd = new RootBeanDefinition(TestTargetSource.class, tsPvs);
 | 
			
		||||
		RootBeanDefinition tsBd = new RootBeanDefinition(TestTargetSource.class);
 | 
			
		||||
		tsBd.setPropertyValues(tsPvs);
 | 
			
		||||
 | 
			
		||||
		MutablePropertyValues pvs = new MutablePropertyValues();
 | 
			
		||||
		RootBeanDefinition bd = new RootBeanDefinition(SerializablePerson.class, pvs);
 | 
			
		||||
		RootBeanDefinition bd = new RootBeanDefinition(SerializablePerson.class);
 | 
			
		||||
		bd.setPropertyValues(pvs);
 | 
			
		||||
		bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
 | 
			
		||||
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,7 +22,9 @@ import static test.util.TestResourceUtils.qualifiedResource;
 | 
			
		|||
import org.junit.Before;
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import org.springframework.beans.factory.BeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 | 
			
		||||
import org.springframework.core.io.Resource;
 | 
			
		||||
 | 
			
		||||
import test.beans.SideEffectBean;
 | 
			
		||||
| 
						 | 
				
			
			@ -43,7 +45,8 @@ public final class PrototypeTargetSourceTests {
 | 
			
		|||
 | 
			
		||||
	@Before
 | 
			
		||||
	public void setUp() throws Exception {
 | 
			
		||||
		this.beanFactory = new XmlBeanFactory(CONTEXT);
 | 
			
		||||
		this.beanFactory = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader((BeanDefinitionRegistry) this.beanFactory).loadBeanDefinitions(CONTEXT);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,12 +16,15 @@
 | 
			
		|||
 | 
			
		||||
package org.springframework.aop.target;
 | 
			
		||||
 | 
			
		||||
import static org.junit.Assert.*;
 | 
			
		||||
import static org.junit.Assert.assertEquals;
 | 
			
		||||
import static org.junit.Assert.assertNotNull;
 | 
			
		||||
import static org.junit.Assert.fail;
 | 
			
		||||
import static test.util.TestResourceUtils.qualifiedResource;
 | 
			
		||||
 | 
			
		||||
import org.junit.Before;
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 | 
			
		||||
import org.springframework.core.io.Resource;
 | 
			
		||||
 | 
			
		||||
import test.beans.ITestBean;
 | 
			
		||||
| 
						 | 
				
			
			@ -39,11 +42,12 @@ public class ThreadLocalTargetSourceTests {
 | 
			
		|||
	/** Initial count value set in bean factory XML */
 | 
			
		||||
	private static final int INITIAL_COUNT = 10;
 | 
			
		||||
 | 
			
		||||
	private XmlBeanFactory beanFactory;
 | 
			
		||||
	private DefaultListableBeanFactory beanFactory;
 | 
			
		||||
 | 
			
		||||
	@Before
 | 
			
		||||
	public void setUp() throws Exception {
 | 
			
		||||
		this.beanFactory = new XmlBeanFactory(CONTEXT);
 | 
			
		||||
		this.beanFactory = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(CONTEXT);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,6 +19,8 @@ package org.springframework.aop.target.dynamic;
 | 
			
		|||
import static org.junit.Assert.*;
 | 
			
		||||
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import org.springframework.tests.Assume;
 | 
			
		||||
import org.springframework.tests.TestGroup;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Rob Harrop
 | 
			
		||||
| 
						 | 
				
			
			@ -75,6 +77,8 @@ public final class RefreshableTargetSourceTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testRefreshOverTime() throws Exception {
 | 
			
		||||
		Assume.group(TestGroup.PERFORMANCE);
 | 
			
		||||
 | 
			
		||||
		CountingRefreshableTargetSource ts = new CountingRefreshableTargetSource(true);
 | 
			
		||||
		ts.setRefreshCheckDelay(100);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,16 +16,18 @@
 | 
			
		|||
 | 
			
		||||
package org.springframework.mock.staticmock;
 | 
			
		||||
 | 
			
		||||
import javax.persistence.PersistenceException;
 | 
			
		||||
import static org.junit.Assert.assertEquals;
 | 
			
		||||
import static org.junit.Assert.fail;
 | 
			
		||||
import static org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl.expectReturn;
 | 
			
		||||
import static org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl.expectThrow;
 | 
			
		||||
import static org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl.playback;
 | 
			
		||||
 | 
			
		||||
import junit.framework.Assert;
 | 
			
		||||
import javax.persistence.PersistenceException;
 | 
			
		||||
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import org.junit.runner.RunWith;
 | 
			
		||||
import org.junit.runners.JUnit4;
 | 
			
		||||
 | 
			
		||||
import static org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl.*;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Test for static entity mocking framework.
 | 
			
		||||
| 
						 | 
				
			
			@ -43,7 +45,7 @@ public class AnnotationDrivenStaticEntityMockingControlTest {
 | 
			
		|||
		Person.countPeople();
 | 
			
		||||
		expectReturn(expectedCount);
 | 
			
		||||
		playback();
 | 
			
		||||
		Assert.assertEquals(expectedCount, Person.countPeople());
 | 
			
		||||
		assertEquals(expectedCount, Person.countPeople());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Test(expected=PersistenceException.class)
 | 
			
		||||
| 
						 | 
				
			
			@ -61,7 +63,7 @@ public class AnnotationDrivenStaticEntityMockingControlTest {
 | 
			
		|||
		Person.findPerson(id);
 | 
			
		||||
		expectReturn(found);
 | 
			
		||||
		playback();
 | 
			
		||||
		Assert.assertEquals(found, Person.findPerson(id));
 | 
			
		||||
		assertEquals(found, Person.findPerson(id));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -81,10 +83,10 @@ public class AnnotationDrivenStaticEntityMockingControlTest {
 | 
			
		|||
		expectReturn(0);
 | 
			
		||||
		playback();
 | 
			
		||||
 | 
			
		||||
		Assert.assertEquals(found1, Person.findPerson(id1));
 | 
			
		||||
		Assert.assertEquals(found2, Person.findPerson(id2));
 | 
			
		||||
		Assert.assertEquals(found1, Person.findPerson(id1));
 | 
			
		||||
		Assert.assertEquals(0, Person.countPeople());
 | 
			
		||||
		assertEquals(found1, Person.findPerson(id1));
 | 
			
		||||
		assertEquals(found2, Person.findPerson(id2));
 | 
			
		||||
		assertEquals(found1, Person.findPerson(id1));
 | 
			
		||||
		assertEquals(0, Person.countPeople());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Note delegation is used when tests are invalid and should fail, as otherwise
 | 
			
		||||
| 
						 | 
				
			
			@ -94,7 +96,7 @@ public class AnnotationDrivenStaticEntityMockingControlTest {
 | 
			
		|||
	public void testArgMethodNoMatchExpectReturn() {
 | 
			
		||||
		try {
 | 
			
		||||
			new Delegate().testArgMethodNoMatchExpectReturn();
 | 
			
		||||
			Assert.fail();
 | 
			
		||||
			fail();
 | 
			
		||||
		} catch (IllegalArgumentException expected) {
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -105,7 +107,7 @@ public class AnnotationDrivenStaticEntityMockingControlTest {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	private void called(Person found, long id) {
 | 
			
		||||
		Assert.assertEquals(found, Person.findPerson(id));
 | 
			
		||||
		assertEquals(found, Person.findPerson(id));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Test
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,12 +16,12 @@
 | 
			
		|||
 | 
			
		||||
package org.springframework.mock.staticmock;
 | 
			
		||||
 | 
			
		||||
import static org.junit.Assert.assertEquals;
 | 
			
		||||
 | 
			
		||||
import java.rmi.RemoteException;
 | 
			
		||||
 | 
			
		||||
import javax.persistence.PersistenceException;
 | 
			
		||||
 | 
			
		||||
import junit.framework.Assert;
 | 
			
		||||
 | 
			
		||||
import org.junit.Ignore;
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl;
 | 
			
		||||
| 
						 | 
				
			
			@ -40,7 +40,7 @@ public class Delegate {
 | 
			
		|||
		Person.findPerson(id);
 | 
			
		||||
		AnnotationDrivenStaticEntityMockingControl.expectReturn(found);
 | 
			
		||||
		AnnotationDrivenStaticEntityMockingControl.playback();
 | 
			
		||||
		Assert.assertEquals(found, Person.findPerson(id + 1));
 | 
			
		||||
		assertEquals(found, Person.findPerson(id + 1));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Test
 | 
			
		||||
| 
						 | 
				
			
			@ -50,7 +50,7 @@ public class Delegate {
 | 
			
		|||
		Person.findPerson(id);
 | 
			
		||||
		AnnotationDrivenStaticEntityMockingControl.expectThrow(new PersistenceException());
 | 
			
		||||
		AnnotationDrivenStaticEntityMockingControl.playback();
 | 
			
		||||
		Assert.assertEquals(found, Person.findPerson(id + 1));
 | 
			
		||||
		assertEquals(found, Person.findPerson(id + 1));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Test
 | 
			
		||||
| 
						 | 
				
			
			@ -62,7 +62,7 @@ public class Delegate {
 | 
			
		|||
		Person.countPeople();
 | 
			
		||||
		AnnotationDrivenStaticEntityMockingControl.expectReturn(25);
 | 
			
		||||
		AnnotationDrivenStaticEntityMockingControl.playback();
 | 
			
		||||
		Assert.assertEquals(found, Person.findPerson(id));
 | 
			
		||||
		assertEquals(found, Person.findPerson(id));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Test
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -41,8 +41,8 @@ import static org.springframework.beans.PropertyDescriptorUtils.*;
 | 
			
		|||
 | 
			
		||||
/**
 | 
			
		||||
 * Decorator for a standard {@link BeanInfo} object, e.g. as created by
 | 
			
		||||
 * {@link Introspector#getBeanInfo(Class)}, designed to discover and register non-void
 | 
			
		||||
 * returning setter methods. For example:
 | 
			
		||||
 * {@link Introspector#getBeanInfo(Class)}, designed to discover and register static
 | 
			
		||||
 * and/or non-void returning setter methods. For example:
 | 
			
		||||
 * <pre>{@code
 | 
			
		||||
 * public class Bean {
 | 
			
		||||
 *     private Foo foo;
 | 
			
		||||
| 
						 | 
				
			
			@ -102,37 +102,40 @@ class ExtendedBeanInfo implements BeanInfo {
 | 
			
		|||
					new SimpleNonIndexedPropertyDescriptor(pd));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for (Method method : findNonVoidWriteMethods(delegate.getMethodDescriptors())) {
 | 
			
		||||
			handleNonVoidWriteMethod(method);
 | 
			
		||||
		for (Method method : findCandidateWriteMethods(delegate.getMethodDescriptors())) {
 | 
			
		||||
			handleCandidateWriteMethod(method);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	private List<Method> findNonVoidWriteMethods(MethodDescriptor[] methodDescriptors) {
 | 
			
		||||
	private List<Method> findCandidateWriteMethods(MethodDescriptor[] methodDescriptors) {
 | 
			
		||||
		List<Method> matches = new ArrayList<Method>();
 | 
			
		||||
		for (MethodDescriptor methodDescriptor : methodDescriptors) {
 | 
			
		||||
			Method method = methodDescriptor.getMethod();
 | 
			
		||||
			if (isNonVoidWriteMethod(method)) {
 | 
			
		||||
			if (isCandidateWriteMethod(method)) {
 | 
			
		||||
				matches.add(method);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		return matches;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public static boolean isNonVoidWriteMethod(Method method) {
 | 
			
		||||
	public static boolean isCandidateWriteMethod(Method method) {
 | 
			
		||||
		String methodName = method.getName();
 | 
			
		||||
		Class<?>[] parameterTypes = method.getParameterTypes();
 | 
			
		||||
		int nParams = parameterTypes.length;
 | 
			
		||||
		if (methodName.length() > 3 && methodName.startsWith("set") &&
 | 
			
		||||
				Modifier.isPublic(method.getModifiers()) &&
 | 
			
		||||
				!void.class.isAssignableFrom(method.getReturnType()) &&
 | 
			
		||||
				(
 | 
			
		||||
						!void.class.isAssignableFrom(method.getReturnType()) ||
 | 
			
		||||
						Modifier.isStatic(method.getModifiers())
 | 
			
		||||
				) &&
 | 
			
		||||
				(nParams == 1 || (nParams == 2 && parameterTypes[0].equals(int.class)))) {
 | 
			
		||||
			return true;
 | 
			
		||||
		}
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private void handleNonVoidWriteMethod(Method method) throws IntrospectionException {
 | 
			
		||||
	private void handleCandidateWriteMethod(Method method) throws IntrospectionException {
 | 
			
		||||
		int nParams = method.getParameterTypes().length;
 | 
			
		||||
		String propertyName = propertyNameFor(method);
 | 
			
		||||
		Class<?> propertyType = method.getParameterTypes()[nParams-1];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -51,7 +51,7 @@ public class ExtendedBeanInfoFactory implements Ordered, BeanInfoFactory {
 | 
			
		|||
	 */
 | 
			
		||||
	private boolean supports(Class<?> beanClass) {
 | 
			
		||||
		for (Method method : beanClass.getMethods()) {
 | 
			
		||||
			if (ExtendedBeanInfo.isNonVoidWriteMethod(method)) {
 | 
			
		||||
			if (ExtendedBeanInfo.isCandidateWriteMethod(method)) {
 | 
			
		||||
				return true;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -234,6 +234,8 @@ public class CustomEditorConfigurer implements BeanFactoryPostProcessor, BeanCla
 | 
			
		|||
			this.sharedEditor = sharedEditor;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		@Override
 | 
			
		||||
		@SuppressWarnings("deprecation")
 | 
			
		||||
		public void registerCustomEditors(PropertyEditorRegistry registry) {
 | 
			
		||||
			if (!(registry instanceof PropertyEditorRegistrySupport)) {
 | 
			
		||||
				throw new IllegalArgumentException("Cannot registered shared editor " +
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -716,6 +716,7 @@ public class BeanDefinitionParserDelegate {
 | 
			
		|||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@SuppressWarnings("deprecation")
 | 
			
		||||
	public int getAutowireMode(String attValue) {
 | 
			
		||||
		String att = attValue;
 | 
			
		||||
		if (DEFAULT_VALUE.equals(att)) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright 2002-2007 the original author or authors.
 | 
			
		||||
 * 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.
 | 
			
		||||
| 
						 | 
				
			
			@ -77,7 +77,7 @@ public class ResourceEntityResolver extends DelegatingEntityResolver {
 | 
			
		|||
			try {
 | 
			
		||||
				String decodedSystemId = URLDecoder.decode(systemId);
 | 
			
		||||
				String givenUrl = new URL(decodedSystemId).toString();
 | 
			
		||||
				String systemRootUrl = new File("").toURL().toString();
 | 
			
		||||
				String systemRootUrl = new File("").toURI().toURL().toString();
 | 
			
		||||
				// Try relative to resource base if currently in system root.
 | 
			
		||||
				if (givenUrl.startsWith(systemRootUrl)) {
 | 
			
		||||
					resourcePath = givenUrl.substring(systemRootUrl.length());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,28 +15,30 @@
 | 
			
		|||
 */
 | 
			
		||||
package com.foo;
 | 
			
		||||
 | 
			
		||||
import static org.hamcrest.CoreMatchers.equalTo;
 | 
			
		||||
import static org.junit.Assert.assertThat;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import org.junit.AfterClass;
 | 
			
		||||
import org.junit.BeforeClass;
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 | 
			
		||||
import org.springframework.core.io.ClassPathResource;
 | 
			
		||||
 | 
			
		||||
import static org.junit.Assert.*;
 | 
			
		||||
import static org.hamcrest.CoreMatchers.*;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Costin Leau
 | 
			
		||||
 */
 | 
			
		||||
public class ComponentBeanDefinitionParserTest {
 | 
			
		||||
 | 
			
		||||
	private static XmlBeanFactory bf;
 | 
			
		||||
	private static DefaultListableBeanFactory bf;
 | 
			
		||||
 | 
			
		||||
	@BeforeClass
 | 
			
		||||
	public static void setUpBeforeClass() throws Exception {
 | 
			
		||||
		bf = new XmlBeanFactory(new ClassPathResource(
 | 
			
		||||
				"com/foo/component-config.xml"));
 | 
			
		||||
		bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
 | 
			
		||||
				new ClassPathResource("com/foo/component-config.xml"));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@AfterClass
 | 
			
		||||
| 
						 | 
				
			
			@ -71,4 +73,4 @@ public class ComponentBeanDefinitionParserTest {
 | 
			
		|||
		assertThat("Karate-1", equalTo(components.get(0).getName()));
 | 
			
		||||
		assertThat("Sport-1", equalTo(components.get(1).getName()));
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -49,8 +49,8 @@ import org.springframework.beans.propertyeditors.CustomNumberEditor;
 | 
			
		|||
import org.springframework.beans.propertyeditors.StringArrayPropertyEditor;
 | 
			
		||||
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
 | 
			
		||||
import org.springframework.beans.support.DerivedFromProtectedBaseBean;
 | 
			
		||||
import org.springframework.build.junit.Assume;
 | 
			
		||||
import org.springframework.build.junit.TestGroup;
 | 
			
		||||
import org.springframework.tests.Assume;
 | 
			
		||||
import org.springframework.tests.TestGroup;
 | 
			
		||||
import org.springframework.core.convert.ConversionFailedException;
 | 
			
		||||
import org.springframework.core.convert.TypeDescriptor;
 | 
			
		||||
import org.springframework.core.convert.support.DefaultConversionService;
 | 
			
		||||
| 
						 | 
				
			
			@ -1550,6 +1550,24 @@ public final class BeanWrapperTests {
 | 
			
		|||
		assertEquals(TestEnum.TEST_VALUE, consumer.getEnumValue());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void cornerSpr10115() {
 | 
			
		||||
		Spr10115Bean foo = new Spr10115Bean();
 | 
			
		||||
		BeanWrapperImpl bwi = new BeanWrapperImpl();
 | 
			
		||||
		bwi.setWrappedInstance(foo);
 | 
			
		||||
		bwi.setPropertyValue("prop1", "val1");
 | 
			
		||||
		assertEquals("val1", Spr10115Bean.prop1);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	static class Spr10115Bean {
 | 
			
		||||
		private static String prop1;
 | 
			
		||||
 | 
			
		||||
		public static void setProp1(String prop1) {
 | 
			
		||||
			Spr10115Bean.prop1 = prop1;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	private static class Foo {
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -946,4 +946,28 @@ public class ExtendedBeanInfoTests {
 | 
			
		|||
			assertThat(hasIndexedWriteMethodForProperty(bi, "address"), is(true));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void shouldSupportStaticWriteMethod() throws IntrospectionException {
 | 
			
		||||
		{
 | 
			
		||||
			BeanInfo bi = Introspector.getBeanInfo(WithStaticWriteMethod.class);
 | 
			
		||||
			assertThat(hasReadMethodForProperty(bi, "prop1"), is(false));
 | 
			
		||||
			assertThat(hasWriteMethodForProperty(bi, "prop1"), is(false));
 | 
			
		||||
			assertThat(hasIndexedReadMethodForProperty(bi, "prop1"), is(false));
 | 
			
		||||
			assertThat(hasIndexedWriteMethodForProperty(bi, "prop1"), is(false));
 | 
			
		||||
		}
 | 
			
		||||
		{
 | 
			
		||||
			BeanInfo bi = new ExtendedBeanInfo(Introspector.getBeanInfo(WithStaticWriteMethod.class));
 | 
			
		||||
			assertThat(hasReadMethodForProperty(bi, "prop1"), is(false));
 | 
			
		||||
			assertThat(hasWriteMethodForProperty(bi, "prop1"), is(true));
 | 
			
		||||
			assertThat(hasIndexedReadMethodForProperty(bi, "prop1"), is(false));
 | 
			
		||||
			assertThat(hasIndexedWriteMethodForProperty(bi, "prop1"), is(false));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	static class WithStaticWriteMethod {
 | 
			
		||||
		@SuppressWarnings("unused")
 | 
			
		||||
		public static void setProp1(String prop1) {
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,16 +16,21 @@
 | 
			
		|||
 | 
			
		||||
package org.springframework.beans.factory;
 | 
			
		||||
 | 
			
		||||
import static org.junit.Assert.assertEquals;
 | 
			
		||||
import static org.junit.Assert.assertTrue;
 | 
			
		||||
import static test.util.TestResourceUtils.qualifiedResource;
 | 
			
		||||
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
import org.junit.Before;
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
 | 
			
		||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.support.StaticListableBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 | 
			
		||||
import org.springframework.cglib.proxy.NoOp;
 | 
			
		||||
import org.springframework.core.io.Resource;
 | 
			
		||||
import org.springframework.util.ObjectUtils;
 | 
			
		||||
| 
						 | 
				
			
			@ -35,9 +40,6 @@ import test.beans.ITestBean;
 | 
			
		|||
import test.beans.IndexedTestBean;
 | 
			
		||||
import test.beans.TestBean;
 | 
			
		||||
 | 
			
		||||
import static org.junit.Assert.*;
 | 
			
		||||
import static test.util.TestResourceUtils.qualifiedResource;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Rod Johnson
 | 
			
		||||
 * @author Juergen Hoeller
 | 
			
		||||
| 
						 | 
				
			
			@ -60,10 +62,17 @@ public final class BeanFactoryUtilsTests {
 | 
			
		|||
	public void setUp() {
 | 
			
		||||
		// Interesting hierarchical factory to test counts.
 | 
			
		||||
		// Slow to read so we cache it.
 | 
			
		||||
		XmlBeanFactory grandParent = new XmlBeanFactory(ROOT_CONTEXT);
 | 
			
		||||
		XmlBeanFactory parent = new XmlBeanFactory(MIDDLE_CONTEXT, grandParent);
 | 
			
		||||
		XmlBeanFactory child = new XmlBeanFactory(LEAF_CONTEXT, parent);
 | 
			
		||||
		this.dependentBeansBF = new XmlBeanFactory(DEPENDENT_BEANS_CONTEXT);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		DefaultListableBeanFactory grandParent = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(grandParent).loadBeanDefinitions(ROOT_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory parent = new DefaultListableBeanFactory(grandParent);
 | 
			
		||||
		new XmlBeanDefinitionReader(parent).loadBeanDefinitions(MIDDLE_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
 | 
			
		||||
		new XmlBeanDefinitionReader(child).loadBeanDefinitions(LEAF_CONTEXT);
 | 
			
		||||
 | 
			
		||||
		this.dependentBeansBF = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader((BeanDefinitionRegistry) this.dependentBeansBF).loadBeanDefinitions(DEPENDENT_BEANS_CONTEXT);
 | 
			
		||||
		dependentBeansBF.preInstantiateSingletons();
 | 
			
		||||
		this.listableBeanFactory = child;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,7 +16,8 @@
 | 
			
		|||
 | 
			
		||||
package org.springframework.beans.factory;
 | 
			
		||||
 | 
			
		||||
import static org.junit.Assert.*;
 | 
			
		||||
import static org.junit.Assert.assertEquals;
 | 
			
		||||
import static org.junit.Assert.fail;
 | 
			
		||||
import static test.util.TestResourceUtils.qualifiedResource;
 | 
			
		||||
 | 
			
		||||
import java.text.DateFormat;
 | 
			
		||||
| 
						 | 
				
			
			@ -34,7 +35,8 @@ import org.junit.Before;
 | 
			
		|||
import org.junit.Test;
 | 
			
		||||
import org.springframework.beans.PropertyEditorRegistrar;
 | 
			
		||||
import org.springframework.beans.PropertyEditorRegistry;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 | 
			
		||||
import org.springframework.beans.propertyeditors.CustomDateEditor;
 | 
			
		||||
import org.springframework.core.io.Resource;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -70,7 +72,8 @@ public final class ConcurrentBeanFactoryTests {
 | 
			
		|||
 | 
			
		||||
	@Before
 | 
			
		||||
	public void setUp() throws Exception {
 | 
			
		||||
		XmlBeanFactory factory = new XmlBeanFactory(CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(factory).loadBeanDefinitions(CONTEXT);
 | 
			
		||||
		factory.addPropertyEditorRegistrar(new PropertyEditorRegistrar() {
 | 
			
		||||
			@Override
 | 
			
		||||
			public void registerCustomEditors(PropertyEditorRegistry registry) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -72,8 +72,8 @@ import org.springframework.beans.factory.support.RootBeanDefinition;
 | 
			
		|||
import org.springframework.beans.factory.xml.ConstructorDependenciesBean;
 | 
			
		||||
import org.springframework.beans.factory.xml.DependenciesBean;
 | 
			
		||||
import org.springframework.beans.propertyeditors.CustomNumberEditor;
 | 
			
		||||
import org.springframework.build.junit.Assume;
 | 
			
		||||
import org.springframework.build.junit.TestGroup;
 | 
			
		||||
import org.springframework.tests.Assume;
 | 
			
		||||
import org.springframework.tests.TestGroup;
 | 
			
		||||
import org.springframework.core.MethodParameter;
 | 
			
		||||
import org.springframework.core.convert.converter.Converter;
 | 
			
		||||
import org.springframework.core.convert.support.DefaultConversionService;
 | 
			
		||||
| 
						 | 
				
			
			@ -549,7 +549,9 @@ public class DefaultListableBeanFactoryTests {
 | 
			
		|||
		DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
 | 
			
		||||
		MutablePropertyValues pvs = new MutablePropertyValues();
 | 
			
		||||
		pvs.add("spouse", new RuntimeBeanReference("self"));
 | 
			
		||||
		lbf.registerBeanDefinition("self", new RootBeanDefinition(TestBean.class, pvs));
 | 
			
		||||
		RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		bd.setPropertyValues(pvs);
 | 
			
		||||
		lbf.registerBeanDefinition("self", bd);
 | 
			
		||||
		TestBean self = (TestBean) lbf.getBean("self");
 | 
			
		||||
		assertEquals(self, self.getSpouse());
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -560,7 +562,9 @@ public class DefaultListableBeanFactoryTests {
 | 
			
		|||
			DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
 | 
			
		||||
			MutablePropertyValues pvs = new MutablePropertyValues();
 | 
			
		||||
			pvs.add("ag", "foobar");
 | 
			
		||||
			lbf.registerBeanDefinition("tb", new RootBeanDefinition(TestBean.class, pvs));
 | 
			
		||||
			RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
			bd.setPropertyValues(pvs);
 | 
			
		||||
			lbf.registerBeanDefinition("tb", bd);
 | 
			
		||||
			lbf.getBean("tb");
 | 
			
		||||
			fail("Should throw exception on invalid property");
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -846,7 +850,9 @@ public class DefaultListableBeanFactoryTests {
 | 
			
		|||
		});
 | 
			
		||||
		MutablePropertyValues pvs = new MutablePropertyValues();
 | 
			
		||||
		pvs.add("myFloat", "1,1");
 | 
			
		||||
		lbf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class, pvs));
 | 
			
		||||
		RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		bd.setPropertyValues(pvs);
 | 
			
		||||
		lbf.registerBeanDefinition("testBean", bd);
 | 
			
		||||
		TestBean testBean = (TestBean) lbf.getBean("testBean");
 | 
			
		||||
		assertTrue(testBean.getMyFloat().floatValue() == 1.1f);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -870,7 +876,9 @@ public class DefaultListableBeanFactoryTests {
 | 
			
		|||
		lbf.setConversionService(conversionService);
 | 
			
		||||
		MutablePropertyValues pvs = new MutablePropertyValues();
 | 
			
		||||
		pvs.add("myFloat", "1,1");
 | 
			
		||||
		lbf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class, pvs));
 | 
			
		||||
		RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		bd.setPropertyValues(pvs);
 | 
			
		||||
		lbf.registerBeanDefinition("testBean", bd);
 | 
			
		||||
		TestBean testBean = (TestBean) lbf.getBean("testBean");
 | 
			
		||||
		assertTrue(testBean.getMyFloat().floatValue() == 1.1f);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -887,7 +895,9 @@ public class DefaultListableBeanFactoryTests {
 | 
			
		|||
		});
 | 
			
		||||
		MutablePropertyValues pvs = new MutablePropertyValues();
 | 
			
		||||
		pvs.add("myFloat", new RuntimeBeanReference("myFloat"));
 | 
			
		||||
		lbf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class, pvs));
 | 
			
		||||
		RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		bd.setPropertyValues(pvs);
 | 
			
		||||
		lbf.registerBeanDefinition("testBean", bd);
 | 
			
		||||
		lbf.registerSingleton("myFloat", "1,1");
 | 
			
		||||
		TestBean testBean = (TestBean) lbf.getBean("testBean");
 | 
			
		||||
		assertTrue(testBean.getMyFloat().floatValue() == 1.1f);
 | 
			
		||||
| 
						 | 
				
			
			@ -990,7 +1000,8 @@ public class DefaultListableBeanFactoryTests {
 | 
			
		|||
		MutablePropertyValues pvs = new MutablePropertyValues();
 | 
			
		||||
		pvs.add("name", "Tony");
 | 
			
		||||
		pvs.add("age", "48");
 | 
			
		||||
		RootBeanDefinition bd = new RootBeanDefinition(DependenciesBean.class, pvs);
 | 
			
		||||
		RootBeanDefinition bd = new RootBeanDefinition(DependenciesBean.class);
 | 
			
		||||
		bd.setPropertyValues(pvs);
 | 
			
		||||
		bd.setDependencyCheck(RootBeanDefinition.DEPENDENCY_CHECK_OBJECTS);
 | 
			
		||||
		bd.setAutowireMode(RootBeanDefinition.AUTOWIRE_BY_TYPE);
 | 
			
		||||
		lbf.registerBeanDefinition("test", bd);
 | 
			
		||||
| 
						 | 
				
			
			@ -1039,7 +1050,8 @@ public class DefaultListableBeanFactoryTests {
 | 
			
		|||
		bf.registerSingleton("resource1", new UrlResource("http://localhost:8080"));
 | 
			
		||||
		bf.registerSingleton("resource2", new UrlResource("http://localhost:9090"));
 | 
			
		||||
 | 
			
		||||
		RootBeanDefinition rbd = new RootBeanDefinition(ArrayBean.class, RootBeanDefinition.AUTOWIRE_BY_TYPE);
 | 
			
		||||
		RootBeanDefinition rbd = new RootBeanDefinition(ArrayBean.class);
 | 
			
		||||
		rbd.setAutowireMode(RootBeanDefinition.AUTOWIRE_BY_TYPE);
 | 
			
		||||
		bf.registerBeanDefinition("arrayBean", rbd);
 | 
			
		||||
		ArrayBean ab = (ArrayBean) bf.getBean("arrayBean");
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1051,7 +1063,8 @@ public class DefaultListableBeanFactoryTests {
 | 
			
		|||
	public void testArrayPropertyWithOptionalAutowiring() throws MalformedURLException {
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
 | 
			
		||||
		RootBeanDefinition rbd = new RootBeanDefinition(ArrayBean.class, RootBeanDefinition.AUTOWIRE_BY_TYPE);
 | 
			
		||||
		RootBeanDefinition rbd = new RootBeanDefinition(ArrayBean.class);
 | 
			
		||||
		rbd.setAutowireMode(RootBeanDefinition.AUTOWIRE_BY_TYPE);
 | 
			
		||||
		bf.registerBeanDefinition("arrayBean", rbd);
 | 
			
		||||
		ArrayBean ab = (ArrayBean) bf.getBean("arrayBean");
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1064,7 +1077,8 @@ public class DefaultListableBeanFactoryTests {
 | 
			
		|||
		bf.registerSingleton("integer1", new Integer(4));
 | 
			
		||||
		bf.registerSingleton("integer2", new Integer(5));
 | 
			
		||||
 | 
			
		||||
		RootBeanDefinition rbd = new RootBeanDefinition(ArrayBean.class, RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
 | 
			
		||||
		RootBeanDefinition rbd = new RootBeanDefinition(ArrayBean.class);
 | 
			
		||||
		rbd.setAutowireMode(RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
 | 
			
		||||
		bf.registerBeanDefinition("arrayBean", rbd);
 | 
			
		||||
		ArrayBean ab = (ArrayBean) bf.getBean("arrayBean");
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1076,7 +1090,8 @@ public class DefaultListableBeanFactoryTests {
 | 
			
		|||
	public void testArrayConstructorWithOptionalAutowiring() {
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
 | 
			
		||||
		RootBeanDefinition rbd = new RootBeanDefinition(ArrayBean.class, RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
 | 
			
		||||
		RootBeanDefinition rbd = new RootBeanDefinition(ArrayBean.class);
 | 
			
		||||
		rbd.setAutowireMode(RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
 | 
			
		||||
		bf.registerBeanDefinition("arrayBean", rbd);
 | 
			
		||||
		ArrayBean ab = (ArrayBean) bf.getBean("arrayBean");
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1091,7 +1106,8 @@ public class DefaultListableBeanFactoryTests {
 | 
			
		|||
		bf.registerSingleton("resource1", new UrlResource("http://localhost:8080"));
 | 
			
		||||
		bf.registerSingleton("resource2", new UrlResource("http://localhost:9090"));
 | 
			
		||||
 | 
			
		||||
		RootBeanDefinition rbd = new RootBeanDefinition(ArrayBean.class, RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
 | 
			
		||||
		RootBeanDefinition rbd = new RootBeanDefinition(ArrayBean.class);
 | 
			
		||||
		rbd.setAutowireMode(RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
 | 
			
		||||
		bf.registerBeanDefinition("arrayBean", rbd);
 | 
			
		||||
		ArrayBean ab = (ArrayBean) bf.getBean("arrayBean");
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1107,7 +1123,8 @@ public class DefaultListableBeanFactoryTests {
 | 
			
		|||
		bf.registerSingleton("resource1", new UrlResource("http://localhost:8080"));
 | 
			
		||||
		bf.registerSingleton("resource2", new UrlResource("http://localhost:9090"));
 | 
			
		||||
 | 
			
		||||
		RootBeanDefinition rbd = new RootBeanDefinition(ArrayBean.class, RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
 | 
			
		||||
		RootBeanDefinition rbd = new RootBeanDefinition(ArrayBean.class);
 | 
			
		||||
		rbd.setAutowireMode(RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
 | 
			
		||||
		bf.registerBeanDefinition("arrayBean", rbd);
 | 
			
		||||
		ArrayBean ab = (ArrayBean) bf.getBean("arrayBean");
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1121,7 +1138,7 @@ public class DefaultListableBeanFactoryTests {
 | 
			
		|||
		RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		lbf.registerBeanDefinition("rod", bd);
 | 
			
		||||
		assertEquals(1, lbf.getBeanDefinitionCount());
 | 
			
		||||
		Object registered = lbf.autowire(NoDependencies.class, AutowireCapableBeanFactory.AUTOWIRE_AUTODETECT, false);
 | 
			
		||||
		Object registered = lbf.autowire(NoDependencies.class, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false);
 | 
			
		||||
		assertEquals(1, lbf.getBeanDefinitionCount());
 | 
			
		||||
		assertTrue(registered instanceof NoDependencies);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -1131,11 +1148,12 @@ public class DefaultListableBeanFactoryTests {
 | 
			
		|||
		DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
 | 
			
		||||
		MutablePropertyValues pvs = new MutablePropertyValues();
 | 
			
		||||
		pvs.add("name", "Rod");
 | 
			
		||||
		RootBeanDefinition bd = new RootBeanDefinition(TestBean.class, pvs);
 | 
			
		||||
		RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		bd.setPropertyValues(pvs);
 | 
			
		||||
		lbf.registerBeanDefinition("rod", bd);
 | 
			
		||||
		assertEquals(1, lbf.getBeanDefinitionCount());
 | 
			
		||||
		// Depends on age, name and spouse (TestBean)
 | 
			
		||||
		Object registered = lbf.autowire(DependenciesBean.class, AutowireCapableBeanFactory.AUTOWIRE_AUTODETECT, true);
 | 
			
		||||
		Object registered = lbf.autowire(DependenciesBean.class, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, true);
 | 
			
		||||
		assertEquals(1, lbf.getBeanDefinitionCount());
 | 
			
		||||
		DependenciesBean kerry = (DependenciesBean) registered;
 | 
			
		||||
		TestBean rod = (TestBean) lbf.getBean("rod");
 | 
			
		||||
| 
						 | 
				
			
			@ -1147,10 +1165,11 @@ public class DefaultListableBeanFactoryTests {
 | 
			
		|||
		DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
 | 
			
		||||
		MutablePropertyValues pvs = new MutablePropertyValues();
 | 
			
		||||
		pvs.add("name", "Rod");
 | 
			
		||||
		RootBeanDefinition bd = new RootBeanDefinition(TestBean.class, pvs);
 | 
			
		||||
		RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		bd.setPropertyValues(pvs);
 | 
			
		||||
		lbf.registerBeanDefinition("rod", bd);
 | 
			
		||||
		assertEquals(1, lbf.getBeanDefinitionCount());
 | 
			
		||||
		Object registered = lbf.autowire(ConstructorDependency.class, AutowireCapableBeanFactory.AUTOWIRE_AUTODETECT, false);
 | 
			
		||||
		Object registered = lbf.autowire(ConstructorDependency.class, AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, false);
 | 
			
		||||
		assertEquals(1, lbf.getBeanDefinitionCount());
 | 
			
		||||
		ConstructorDependency kerry = (ConstructorDependency) registered;
 | 
			
		||||
		TestBean rod = (TestBean) lbf.getBean("rod");
 | 
			
		||||
| 
						 | 
				
			
			@ -1165,7 +1184,7 @@ public class DefaultListableBeanFactoryTests {
 | 
			
		|||
		RootBeanDefinition bd2 = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		lbf.registerBeanDefinition("rod2", bd2);
 | 
			
		||||
		try {
 | 
			
		||||
			lbf.autowire(ConstructorDependency.class, AutowireCapableBeanFactory.AUTOWIRE_AUTODETECT, false);
 | 
			
		||||
			lbf.autowire(ConstructorDependency.class, AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, false);
 | 
			
		||||
			fail("Should have thrown UnsatisfiedDependencyException");
 | 
			
		||||
		}
 | 
			
		||||
		catch (UnsatisfiedDependencyException ex) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1180,11 +1199,12 @@ public class DefaultListableBeanFactoryTests {
 | 
			
		|||
		DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
 | 
			
		||||
		MutablePropertyValues pvs = new MutablePropertyValues();
 | 
			
		||||
		pvs.addPropertyValue(new PropertyValue("name", "Rod"));
 | 
			
		||||
		RootBeanDefinition bd = new RootBeanDefinition(TestBean.class, pvs);
 | 
			
		||||
		RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		bd.setPropertyValues(pvs);
 | 
			
		||||
		lbf.registerBeanDefinition("rod", bd);
 | 
			
		||||
		assertEquals(1, lbf.getBeanDefinitionCount());
 | 
			
		||||
		try {
 | 
			
		||||
			lbf.autowire(UnsatisfiedConstructorDependency.class, AutowireCapableBeanFactory.AUTOWIRE_AUTODETECT, true);
 | 
			
		||||
			lbf.autowire(UnsatisfiedConstructorDependency.class, AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, true);
 | 
			
		||||
			fail("Should have unsatisfied constructor dependency on SideEffectBean");
 | 
			
		||||
		}
 | 
			
		||||
		catch (UnsatisfiedDependencyException ex) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1467,7 +1487,9 @@ public class DefaultListableBeanFactoryTests {
 | 
			
		|||
		DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
 | 
			
		||||
		MutablePropertyValues pvs = new MutablePropertyValues();
 | 
			
		||||
		pvs.add("age", "99");
 | 
			
		||||
		lbf.registerBeanDefinition("test", new RootBeanDefinition(TestBean.class, pvs));
 | 
			
		||||
		RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		bd.setPropertyValues(pvs);
 | 
			
		||||
		lbf.registerBeanDefinition("test", bd);
 | 
			
		||||
		TestBean tb = new TestBean();
 | 
			
		||||
		assertEquals(0, tb.getAge());
 | 
			
		||||
		lbf.applyBeanPropertyValues(tb, "test");
 | 
			
		||||
| 
						 | 
				
			
			@ -1479,7 +1501,9 @@ public class DefaultListableBeanFactoryTests {
 | 
			
		|||
		DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
 | 
			
		||||
		MutablePropertyValues pvs = new MutablePropertyValues();
 | 
			
		||||
		pvs.add("age", "99");
 | 
			
		||||
		lbf.registerBeanDefinition("test", new RootBeanDefinition(null, pvs));
 | 
			
		||||
		RootBeanDefinition bd = new RootBeanDefinition();
 | 
			
		||||
		bd.setPropertyValues(pvs);
 | 
			
		||||
		lbf.registerBeanDefinition("test", bd);
 | 
			
		||||
		TestBean tb = new TestBean();
 | 
			
		||||
		assertEquals(0, tb.getAge());
 | 
			
		||||
		lbf.applyBeanPropertyValues(tb, "test");
 | 
			
		||||
| 
						 | 
				
			
			@ -1493,7 +1517,9 @@ public class DefaultListableBeanFactoryTests {
 | 
			
		|||
		DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
 | 
			
		||||
		MutablePropertyValues pvs = new MutablePropertyValues();
 | 
			
		||||
		pvs.add("age", "99");
 | 
			
		||||
		lbf.registerBeanDefinition("test", new RootBeanDefinition(TestBean.class, pvs));
 | 
			
		||||
		RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		bd.setPropertyValues(pvs);
 | 
			
		||||
		lbf.registerBeanDefinition("test", bd);
 | 
			
		||||
		TestBean tb = new TestBean();
 | 
			
		||||
		assertEquals(0, tb.getAge());
 | 
			
		||||
		lbf.configureBean(tb, "test");
 | 
			
		||||
| 
						 | 
				
			
			@ -1509,7 +1535,9 @@ public class DefaultListableBeanFactoryTests {
 | 
			
		|||
		lbf.registerBeanDefinition("spouse", bd);
 | 
			
		||||
		MutablePropertyValues pvs = new MutablePropertyValues();
 | 
			
		||||
		pvs.add("age", "99");
 | 
			
		||||
		lbf.registerBeanDefinition("test", new RootBeanDefinition(TestBean.class, RootBeanDefinition.AUTOWIRE_BY_NAME));
 | 
			
		||||
		RootBeanDefinition tbd = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		tbd.setAutowireMode(RootBeanDefinition.AUTOWIRE_BY_NAME);
 | 
			
		||||
		lbf.registerBeanDefinition("test", tbd);
 | 
			
		||||
		TestBean tb = new TestBean();
 | 
			
		||||
		lbf.configureBean(tb, "test");
 | 
			
		||||
		assertSame(lbf, tb.getBeanFactory());
 | 
			
		||||
| 
						 | 
				
			
			@ -1523,7 +1551,8 @@ public class DefaultListableBeanFactoryTests {
 | 
			
		|||
		for (int i = 0; i < 1000; i++) {
 | 
			
		||||
			MutablePropertyValues pvs = new MutablePropertyValues();
 | 
			
		||||
			pvs.addPropertyValue(new PropertyValue("spouse", new RuntimeBeanReference("bean" + (i < 99 ? i + 1 : 0))));
 | 
			
		||||
			RootBeanDefinition bd = new RootBeanDefinition(TestBean.class, pvs);
 | 
			
		||||
			RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
			bd.setPropertyValues(pvs);
 | 
			
		||||
			lbf.registerBeanDefinition("bean" + i, bd);
 | 
			
		||||
		}
 | 
			
		||||
		lbf.preInstantiateSingletons();
 | 
			
		||||
| 
						 | 
				
			
			@ -1537,7 +1566,9 @@ public class DefaultListableBeanFactoryTests {
 | 
			
		|||
	@Test
 | 
			
		||||
	public void testCircularReferenceThroughAutowiring() {
 | 
			
		||||
		DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
 | 
			
		||||
		lbf.registerBeanDefinition("test", new RootBeanDefinition(ConstructorDependencyBean.class, RootBeanDefinition.AUTOWIRE_CONSTRUCTOR));
 | 
			
		||||
		RootBeanDefinition bd = new RootBeanDefinition(ConstructorDependencyBean.class);
 | 
			
		||||
		bd.setAutowireMode(RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
 | 
			
		||||
		lbf.registerBeanDefinition("test", bd);
 | 
			
		||||
		try {
 | 
			
		||||
			lbf.preInstantiateSingletons();
 | 
			
		||||
			fail("Should have thrown UnsatisfiedDependencyException");
 | 
			
		||||
| 
						 | 
				
			
			@ -1549,7 +1580,9 @@ public class DefaultListableBeanFactoryTests {
 | 
			
		|||
	@Test
 | 
			
		||||
	public void testCircularReferenceThroughFactoryBeanAutowiring() {
 | 
			
		||||
		DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
 | 
			
		||||
		lbf.registerBeanDefinition("test", new RootBeanDefinition(ConstructorDependencyFactoryBean.class, RootBeanDefinition.AUTOWIRE_CONSTRUCTOR));
 | 
			
		||||
		RootBeanDefinition bd = new RootBeanDefinition(ConstructorDependencyFactoryBean.class);
 | 
			
		||||
		bd.setAutowireMode(RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
 | 
			
		||||
		lbf.registerBeanDefinition("test", bd);
 | 
			
		||||
		try {
 | 
			
		||||
			lbf.preInstantiateSingletons();
 | 
			
		||||
			fail("Should have thrown UnsatisfiedDependencyException");
 | 
			
		||||
| 
						 | 
				
			
			@ -1561,7 +1594,9 @@ public class DefaultListableBeanFactoryTests {
 | 
			
		|||
	@Test
 | 
			
		||||
	public void testCircularReferenceThroughFactoryBeanTypeCheck() {
 | 
			
		||||
		DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
 | 
			
		||||
		lbf.registerBeanDefinition("test", new RootBeanDefinition(ConstructorDependencyFactoryBean.class, RootBeanDefinition.AUTOWIRE_CONSTRUCTOR));
 | 
			
		||||
		RootBeanDefinition bd = new RootBeanDefinition(ConstructorDependencyFactoryBean.class);
 | 
			
		||||
		bd.setAutowireMode(RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
 | 
			
		||||
		lbf.registerBeanDefinition("test", bd);
 | 
			
		||||
		try {
 | 
			
		||||
			lbf.getBeansOfType(String.class);
 | 
			
		||||
			fail("Should have thrown UnsatisfiedDependencyException");
 | 
			
		||||
| 
						 | 
				
			
			@ -1573,9 +1608,12 @@ public class DefaultListableBeanFactoryTests {
 | 
			
		|||
	@Test
 | 
			
		||||
	public void testAvoidCircularReferenceThroughAutowiring() {
 | 
			
		||||
		DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
 | 
			
		||||
		lbf.registerBeanDefinition("test", new RootBeanDefinition(ConstructorDependencyFactoryBean.class, RootBeanDefinition.AUTOWIRE_CONSTRUCTOR));
 | 
			
		||||
		lbf.registerBeanDefinition("string",
 | 
			
		||||
				new RootBeanDefinition(String.class, RootBeanDefinition.AUTOWIRE_CONSTRUCTOR));
 | 
			
		||||
		RootBeanDefinition bd = new RootBeanDefinition(ConstructorDependencyFactoryBean.class);
 | 
			
		||||
		bd.setAutowireMode(RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
 | 
			
		||||
		lbf.registerBeanDefinition("test", bd);
 | 
			
		||||
		RootBeanDefinition bd2 = new RootBeanDefinition(String.class);
 | 
			
		||||
		bd2.setAutowireMode(RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
 | 
			
		||||
		lbf.registerBeanDefinition("string", bd2);
 | 
			
		||||
		lbf.preInstantiateSingletons();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,9 +22,10 @@ import static org.junit.Assert.assertThat;
 | 
			
		|||
 | 
			
		||||
import org.junit.Before;
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import org.springframework.beans.factory.BeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.config.AbstractFactoryBean;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 | 
			
		||||
import org.springframework.core.io.ClassPathResource;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			@ -37,7 +38,8 @@ public class FactoryBeanLookupTests {
 | 
			
		|||
 | 
			
		||||
	@Before
 | 
			
		||||
	public void setUp() {
 | 
			
		||||
		beanFactory = new XmlBeanFactory(
 | 
			
		||||
		beanFactory = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader((BeanDefinitionRegistry) beanFactory).loadBeanDefinitions(
 | 
			
		||||
				new ClassPathResource("FactoryBeanLookupTests-context.xml", this.getClass()));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,12 +16,15 @@
 | 
			
		|||
 | 
			
		||||
package org.springframework.beans.factory;
 | 
			
		||||
 | 
			
		||||
import static org.junit.Assert.*;
 | 
			
		||||
import static org.junit.Assert.assertEquals;
 | 
			
		||||
import static org.junit.Assert.assertNull;
 | 
			
		||||
import static org.junit.Assert.assertSame;
 | 
			
		||||
import static test.util.TestResourceUtils.qualifiedResource;
 | 
			
		||||
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 | 
			
		||||
import org.springframework.core.io.Resource;
 | 
			
		||||
import org.springframework.util.Assert;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -38,14 +41,16 @@ public final class FactoryBeanTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testFactoryBeanReturnsNull() throws Exception {
 | 
			
		||||
		XmlBeanFactory factory = new XmlBeanFactory(RETURNS_NULL_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(factory).loadBeanDefinitions(RETURNS_NULL_CONTEXT);
 | 
			
		||||
		Object result = factory.getBean("factoryBean");
 | 
			
		||||
		assertNull(result);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testFactoryBeansWithAutowiring() throws Exception {
 | 
			
		||||
		XmlBeanFactory factory = new XmlBeanFactory(WITH_AUTOWIRING_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(factory).loadBeanDefinitions(WITH_AUTOWIRING_CONTEXT);
 | 
			
		||||
 | 
			
		||||
		BeanFactoryPostProcessor ppc = (BeanFactoryPostProcessor) factory.getBean("propertyPlaceholderConfigurer");
 | 
			
		||||
		ppc.postProcessBeanFactory(factory);
 | 
			
		||||
| 
						 | 
				
			
			@ -62,7 +67,8 @@ public final class FactoryBeanTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testFactoryBeansWithIntermediateFactoryBeanAutowiringFailure() throws Exception {
 | 
			
		||||
		XmlBeanFactory factory = new XmlBeanFactory(WITH_AUTOWIRING_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(factory).loadBeanDefinitions(WITH_AUTOWIRING_CONTEXT);
 | 
			
		||||
 | 
			
		||||
		BeanFactoryPostProcessor ppc = (BeanFactoryPostProcessor) factory.getBean("propertyPlaceholderConfigurer");
 | 
			
		||||
		ppc.postProcessBeanFactory(factory);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,6 +16,14 @@
 | 
			
		|||
 | 
			
		||||
package org.springframework.beans.factory.annotation;
 | 
			
		||||
 | 
			
		||||
import static org.junit.Assert.assertEquals;
 | 
			
		||||
import static org.junit.Assert.assertNotNull;
 | 
			
		||||
import static org.junit.Assert.assertNotSame;
 | 
			
		||||
import static org.junit.Assert.assertNull;
 | 
			
		||||
import static org.junit.Assert.assertSame;
 | 
			
		||||
import static org.junit.Assert.assertTrue;
 | 
			
		||||
import static org.junit.Assert.fail;
 | 
			
		||||
 | 
			
		||||
import java.io.Serializable;
 | 
			
		||||
import java.lang.annotation.ElementType;
 | 
			
		||||
import java.lang.annotation.Retention;
 | 
			
		||||
| 
						 | 
				
			
			@ -25,15 +33,11 @@ import java.util.List;
 | 
			
		|||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import test.beans.ITestBean;
 | 
			
		||||
import test.beans.IndexedTestBean;
 | 
			
		||||
import test.beans.NestedTestBean;
 | 
			
		||||
import test.beans.TestBean;
 | 
			
		||||
 | 
			
		||||
import org.springframework.beans.factory.BeanCreationException;
 | 
			
		||||
import org.springframework.beans.factory.BeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.FactoryBean;
 | 
			
		||||
import org.springframework.beans.factory.ObjectFactory;
 | 
			
		||||
import org.springframework.beans.factory.config.BeanDefinition;
 | 
			
		||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.support.AutowireCandidateQualifier;
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
| 
						 | 
				
			
			@ -41,7 +45,10 @@ import org.springframework.beans.factory.support.GenericBeanDefinition;
 | 
			
		|||
import org.springframework.beans.factory.support.RootBeanDefinition;
 | 
			
		||||
import org.springframework.util.SerializationTestUtils;
 | 
			
		||||
 | 
			
		||||
import static org.junit.Assert.*;
 | 
			
		||||
import test.beans.ITestBean;
 | 
			
		||||
import test.beans.IndexedTestBean;
 | 
			
		||||
import test.beans.NestedTestBean;
 | 
			
		||||
import test.beans.TestBean;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Unit tests for {@link AutowiredAnnotationBeanPostProcessor}.
 | 
			
		||||
| 
						 | 
				
			
			@ -608,7 +615,9 @@ public final class AutowiredAnnotationBeanPostProcessorTests {
 | 
			
		|||
		AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
 | 
			
		||||
		bpp.setBeanFactory(bf);
 | 
			
		||||
		bf.addBeanPostProcessor(bpp);
 | 
			
		||||
		bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ObjectFactoryInjectionBean.class, false));
 | 
			
		||||
		RootBeanDefinition annotatedBeanDefinition = new RootBeanDefinition(ObjectFactoryInjectionBean.class);
 | 
			
		||||
		annotatedBeanDefinition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
 | 
			
		||||
		bf.registerBeanDefinition("annotatedBean", annotatedBeanDefinition);
 | 
			
		||||
		bf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class));
 | 
			
		||||
 | 
			
		||||
		ObjectFactoryInjectionBean bean = (ObjectFactoryInjectionBean) bf.getBean("annotatedBean");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -32,6 +32,7 @@ import test.beans.TestBean;
 | 
			
		|||
import org.springframework.beans.factory.BeanCreationException;
 | 
			
		||||
import org.springframework.beans.factory.BeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.FactoryBean;
 | 
			
		||||
import org.springframework.beans.factory.config.BeanDefinition;
 | 
			
		||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.support.AutowireCandidateQualifier;
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
| 
						 | 
				
			
			@ -406,7 +407,9 @@ public class InjectAnnotationBeanPostProcessorTests {
 | 
			
		|||
		AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
 | 
			
		||||
		bpp.setBeanFactory(bf);
 | 
			
		||||
		bf.addBeanPostProcessor(bpp);
 | 
			
		||||
		bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ObjectFactoryQualifierFieldInjectionBean.class, false));
 | 
			
		||||
		RootBeanDefinition annotatedBeanDefinition = new RootBeanDefinition(ObjectFactoryQualifierFieldInjectionBean.class);
 | 
			
		||||
		annotatedBeanDefinition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
 | 
			
		||||
		bf.registerBeanDefinition("annotatedBean", annotatedBeanDefinition);
 | 
			
		||||
		RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		bd.addQualifier(new AutowireCandidateQualifier(Qualifier.class, "testBean"));
 | 
			
		||||
		bf.registerBeanDefinition("testBean", bd);
 | 
			
		||||
| 
						 | 
				
			
			@ -426,7 +429,9 @@ public class InjectAnnotationBeanPostProcessorTests {
 | 
			
		|||
		AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
 | 
			
		||||
		bpp.setBeanFactory(bf);
 | 
			
		||||
		bf.addBeanPostProcessor(bpp);
 | 
			
		||||
		bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ObjectFactoryQualifierMethodInjectionBean.class, false));
 | 
			
		||||
		RootBeanDefinition annotatedBeanDefinition = new RootBeanDefinition(ObjectFactoryQualifierMethodInjectionBean.class);
 | 
			
		||||
		annotatedBeanDefinition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
 | 
			
		||||
		bf.registerBeanDefinition("annotatedBean", annotatedBeanDefinition);
 | 
			
		||||
		RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		bd.addQualifier(new AutowireCandidateQualifier(Qualifier.class, "testBean"));
 | 
			
		||||
		bf.registerBeanDefinition("testBean", bd);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright 2002-2008 the original author or authors.
 | 
			
		||||
 * 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.
 | 
			
		||||
| 
						 | 
				
			
			@ -27,6 +27,7 @@ import org.junit.Test;
 | 
			
		|||
 * @author Rick Evans
 | 
			
		||||
 * @author Chris Beams
 | 
			
		||||
 */
 | 
			
		||||
@SuppressWarnings("deprecation")
 | 
			
		||||
public final class CommonsLogFactoryBeanTests {
 | 
			
		||||
 | 
			
		||||
	@Test
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -62,10 +62,14 @@ public final class CustomEditorConfigurerTests {
 | 
			
		|||
 | 
			
		||||
		MutablePropertyValues pvs = new MutablePropertyValues();
 | 
			
		||||
		pvs.add("date", "2.12.1975");
 | 
			
		||||
		bf.registerBeanDefinition("tb1", new RootBeanDefinition(TestBean.class, pvs));
 | 
			
		||||
		RootBeanDefinition bd1 = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		bd1.setPropertyValues(pvs);
 | 
			
		||||
		bf.registerBeanDefinition("tb1", bd1);
 | 
			
		||||
		pvs = new MutablePropertyValues();
 | 
			
		||||
		pvs.add("someMap[myKey]", new TypedStringValue("2.12.1975", Date.class));
 | 
			
		||||
		bf.registerBeanDefinition("tb2", new RootBeanDefinition(TestBean.class, pvs));
 | 
			
		||||
		RootBeanDefinition bd2 = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		bd2.setPropertyValues(pvs);
 | 
			
		||||
		bf.registerBeanDefinition("tb2", bd2);
 | 
			
		||||
 | 
			
		||||
		TestBean tb1 = (TestBean) bf.getBean("tb1");
 | 
			
		||||
		assertEquals(df.parse("2.12.1975"), tb1.getDate());
 | 
			
		||||
| 
						 | 
				
			
			@ -85,10 +89,14 @@ public final class CustomEditorConfigurerTests {
 | 
			
		|||
 | 
			
		||||
		MutablePropertyValues pvs = new MutablePropertyValues();
 | 
			
		||||
		pvs.add("date", "2.12.1975");
 | 
			
		||||
		bf.registerBeanDefinition("tb1", new RootBeanDefinition(TestBean.class, pvs));
 | 
			
		||||
		RootBeanDefinition bd1 = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		bd1.setPropertyValues(pvs);
 | 
			
		||||
		bf.registerBeanDefinition("tb1", bd1);
 | 
			
		||||
		pvs = new MutablePropertyValues();
 | 
			
		||||
		pvs.add("someMap[myKey]", new TypedStringValue("2.12.1975", Date.class));
 | 
			
		||||
		bf.registerBeanDefinition("tb2", new RootBeanDefinition(TestBean.class, pvs));
 | 
			
		||||
		RootBeanDefinition bd2 = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		bd2.setPropertyValues(pvs);
 | 
			
		||||
		bf.registerBeanDefinition("tb2", bd2);
 | 
			
		||||
 | 
			
		||||
		TestBean tb1 = (TestBean) bf.getBean("tb1");
 | 
			
		||||
		assertEquals(df.parse("2.12.1975"), tb1.getDate());
 | 
			
		||||
| 
						 | 
				
			
			@ -107,7 +115,9 @@ public final class CustomEditorConfigurerTests {
 | 
			
		|||
 | 
			
		||||
		MutablePropertyValues pvs = new MutablePropertyValues();
 | 
			
		||||
		pvs.add("date", "2.12.1975");
 | 
			
		||||
		bf.registerBeanDefinition("tb", new RootBeanDefinition(TestBean.class, pvs));
 | 
			
		||||
		RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		bd.setPropertyValues(pvs);
 | 
			
		||||
		bf.registerBeanDefinition("tb", bd);
 | 
			
		||||
 | 
			
		||||
		TestBean tb = (TestBean) bf.getBean("tb");
 | 
			
		||||
		DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.GERMAN);
 | 
			
		||||
| 
						 | 
				
			
			@ -125,7 +135,9 @@ public final class CustomEditorConfigurerTests {
 | 
			
		|||
 | 
			
		||||
		MutablePropertyValues pvs = new MutablePropertyValues();
 | 
			
		||||
		pvs.add("date", "2.12.1975");
 | 
			
		||||
		bf.registerBeanDefinition("tb", new RootBeanDefinition(TestBean.class, pvs));
 | 
			
		||||
		RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		bd.setPropertyValues(pvs);
 | 
			
		||||
		bf.registerBeanDefinition("tb", bd);
 | 
			
		||||
 | 
			
		||||
		TestBean tb = (TestBean) bf.getBean("tb");
 | 
			
		||||
		DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.GERMAN);
 | 
			
		||||
| 
						 | 
				
			
			@ -143,7 +155,9 @@ public final class CustomEditorConfigurerTests {
 | 
			
		|||
 | 
			
		||||
		MutablePropertyValues pvs = new MutablePropertyValues();
 | 
			
		||||
		pvs.add("stringArray", "xxx");
 | 
			
		||||
		bf.registerBeanDefinition("tb", new RootBeanDefinition(TestBean.class, pvs));
 | 
			
		||||
		RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		bd.setPropertyValues(pvs);
 | 
			
		||||
		bf.registerBeanDefinition("tb", bd);
 | 
			
		||||
 | 
			
		||||
		TestBean tb = (TestBean) bf.getBean("tb");
 | 
			
		||||
		assertTrue(tb.getStringArray() != null && tb.getStringArray().length == 1);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -38,6 +38,7 @@ public class DeprecatedBeanWarnerTests {
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
	@Test
 | 
			
		||||
	@SuppressWarnings("deprecation")
 | 
			
		||||
	public void postProcess() {
 | 
			
		||||
		beanFactory = new DefaultListableBeanFactory();
 | 
			
		||||
		BeanDefinition def = new RootBeanDefinition(MyDeprecatedBean.class);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,21 +16,25 @@
 | 
			
		|||
 | 
			
		||||
package org.springframework.beans.factory.config;
 | 
			
		||||
 | 
			
		||||
import static org.junit.Assert.assertEquals;
 | 
			
		||||
import static org.junit.Assert.assertSame;
 | 
			
		||||
import static org.junit.Assert.assertTrue;
 | 
			
		||||
import static org.junit.Assert.fail;
 | 
			
		||||
import static org.mockito.BDDMockito.given;
 | 
			
		||||
import static org.mockito.Mockito.mock;
 | 
			
		||||
import static test.util.TestResourceUtils.qualifiedResource;
 | 
			
		||||
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
 | 
			
		||||
import javax.inject.Provider;
 | 
			
		||||
 | 
			
		||||
import org.junit.After;
 | 
			
		||||
import static org.junit.Assert.*;
 | 
			
		||||
import static org.mockito.BDDMockito.given;
 | 
			
		||||
import static org.mockito.Mockito.mock;
 | 
			
		||||
 | 
			
		||||
import org.junit.Before;
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import static test.util.TestResourceUtils.*;
 | 
			
		||||
 | 
			
		||||
import org.springframework.beans.factory.BeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.ObjectFactory;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 | 
			
		||||
import org.springframework.core.io.Resource;
 | 
			
		||||
import org.springframework.util.SerializationTestUtils;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -45,11 +49,12 @@ public class ObjectFactoryCreatingFactoryBeanTests {
 | 
			
		|||
	private static final Resource CONTEXT =
 | 
			
		||||
		qualifiedResource(ObjectFactoryCreatingFactoryBeanTests.class, "context.xml");
 | 
			
		||||
 | 
			
		||||
	private XmlBeanFactory beanFactory;
 | 
			
		||||
	private DefaultListableBeanFactory beanFactory;
 | 
			
		||||
 | 
			
		||||
	@Before
 | 
			
		||||
	public void setUp() {
 | 
			
		||||
		this.beanFactory = new XmlBeanFactory(CONTEXT);
 | 
			
		||||
		this.beanFactory = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(CONTEXT);
 | 
			
		||||
		this.beanFactory.setSerializationId("test");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,11 +16,15 @@
 | 
			
		|||
 | 
			
		||||
package org.springframework.beans.factory.config;
 | 
			
		||||
 | 
			
		||||
import static org.junit.Assert.*;
 | 
			
		||||
import static org.junit.Assert.assertEquals;
 | 
			
		||||
import static org.junit.Assert.assertNull;
 | 
			
		||||
import static org.junit.Assert.assertSame;
 | 
			
		||||
import static org.junit.Assert.assertTrue;
 | 
			
		||||
import static test.util.TestResourceUtils.qualifiedResource;
 | 
			
		||||
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 | 
			
		||||
import org.springframework.core.io.Resource;
 | 
			
		||||
 | 
			
		||||
import test.beans.ITestBean;
 | 
			
		||||
| 
						 | 
				
			
			@ -39,7 +43,8 @@ public class PropertyPathFactoryBeanTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testPropertyPathFactoryBeanWithSingletonResult() {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONTEXT);
 | 
			
		||||
		assertEquals(new Integer(12), xbf.getBean("propertyPath1"));
 | 
			
		||||
		assertEquals(new Integer(11), xbf.getBean("propertyPath2"));
 | 
			
		||||
		assertEquals(new Integer(10), xbf.getBean("tb.age"));
 | 
			
		||||
| 
						 | 
				
			
			@ -53,7 +58,8 @@ public class PropertyPathFactoryBeanTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testPropertyPathFactoryBeanWithPrototypeResult() {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONTEXT);
 | 
			
		||||
		assertNull(xbf.getType("tb.spouse"));
 | 
			
		||||
		assertEquals(TestBean.class, xbf.getType("propertyPath3"));
 | 
			
		||||
		Object result1 = xbf.getBean("tb.spouse");
 | 
			
		||||
| 
						 | 
				
			
			@ -72,14 +78,16 @@ public class PropertyPathFactoryBeanTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testPropertyPathFactoryBeanWithNullResult() {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONTEXT);
 | 
			
		||||
		assertNull(xbf.getType("tb.spouse.spouse"));
 | 
			
		||||
		assertNull(xbf.getBean("tb.spouse.spouse"));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testPropertyPathFactoryBeanAsInnerBean() {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONTEXT);
 | 
			
		||||
		TestBean spouse = (TestBean) xbf.getBean("otb.spouse");
 | 
			
		||||
		TestBean tbWithInner = (TestBean) xbf.getBean("tbWithInner");
 | 
			
		||||
		assertSame(spouse, tbWithInner.getSpouse());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -371,7 +371,8 @@ public final class PropertyResourceConfigurerTests {
 | 
			
		|||
			pvs2.add("name", "name${var}${var}${");
 | 
			
		||||
			pvs2.add("spouse", new RuntimeBeanReference("${ref}"));
 | 
			
		||||
			pvs2.add("someMap", singletonMap);
 | 
			
		||||
			RootBeanDefinition parent = new RootBeanDefinition(TestBean.class, pvs1);
 | 
			
		||||
			RootBeanDefinition parent = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
			parent.setPropertyValues(pvs1);
 | 
			
		||||
			ChildBeanDefinition bd = new ChildBeanDefinition("${parent}", pvs2);
 | 
			
		||||
			factory.registerBeanDefinition("parent1", parent);
 | 
			
		||||
			factory.registerBeanDefinition("tb1", bd);
 | 
			
		||||
| 
						 | 
				
			
			@ -382,7 +383,8 @@ public final class PropertyResourceConfigurerTests {
 | 
			
		|||
			pvs.add("name", "name${var}${var}${");
 | 
			
		||||
			pvs.add("spouse", new RuntimeBeanReference("${ref}"));
 | 
			
		||||
			pvs.add("someMap", singletonMap);
 | 
			
		||||
			RootBeanDefinition bd = new RootBeanDefinition(TestBean.class, pvs);
 | 
			
		||||
			RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
			bd.setPropertyValues(pvs);
 | 
			
		||||
			factory.registerBeanDefinition("tb1", bd);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -412,7 +414,9 @@ public final class PropertyResourceConfigurerTests {
 | 
			
		|||
		someMap.put("key2", "${age}name");
 | 
			
		||||
		MutablePropertyValues innerPvs = new MutablePropertyValues();
 | 
			
		||||
		innerPvs.add("touchy", "${os.name}");
 | 
			
		||||
		someMap.put("key3", new RootBeanDefinition(TestBean.class, innerPvs));
 | 
			
		||||
		RootBeanDefinition innerBd = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		innerBd.setPropertyValues(innerPvs);
 | 
			
		||||
		someMap.put("key3", innerBd);
 | 
			
		||||
		MutablePropertyValues innerPvs2 = new MutablePropertyValues(innerPvs);
 | 
			
		||||
		someMap.put("${key4}", new BeanDefinitionHolder(new ChildBeanDefinition("tb1", innerPvs2), "child"));
 | 
			
		||||
		pvs.add("someMap", someMap);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright 2002-2007 the original author or authors.
 | 
			
		||||
 * 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.
 | 
			
		||||
| 
						 | 
				
			
			@ -20,6 +20,8 @@ import java.util.Arrays;
 | 
			
		|||
 | 
			
		||||
import junit.framework.TestCase;
 | 
			
		||||
 | 
			
		||||
import org.springframework.beans.factory.config.BeanDefinition;
 | 
			
		||||
 | 
			
		||||
import test.beans.TestBean;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			@ -31,7 +33,8 @@ public class BeanDefinitionBuilderTests extends TestCase {
 | 
			
		|||
	public void testBeanClassWithSimpleProperty() {
 | 
			
		||||
		String[] dependsOn = new String[] { "A", "B", "C" };
 | 
			
		||||
		BeanDefinitionBuilder bdb = BeanDefinitionBuilder.rootBeanDefinition(TestBean.class);
 | 
			
		||||
		bdb.setSingleton(false).addPropertyReference("age", "15");
 | 
			
		||||
		bdb.setScope(BeanDefinition.SCOPE_PROTOTYPE);
 | 
			
		||||
		bdb.addPropertyReference("age", "15");
 | 
			
		||||
		for (int i = 0; i < dependsOn.length; i++) {
 | 
			
		||||
			bdb.addDependsOn(dependsOn[i]);
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright 2002-2006 the original author or authors.
 | 
			
		||||
 * 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.
 | 
			
		||||
| 
						 | 
				
			
			@ -18,6 +18,7 @@ package org.springframework.beans.factory.support;
 | 
			
		|||
 | 
			
		||||
import junit.framework.TestCase;
 | 
			
		||||
 | 
			
		||||
import org.springframework.beans.factory.config.BeanDefinition;
 | 
			
		||||
import org.springframework.beans.factory.config.BeanDefinitionHolder;
 | 
			
		||||
 | 
			
		||||
import test.beans.TestBean;
 | 
			
		||||
| 
						 | 
				
			
			@ -120,10 +121,11 @@ public class BeanDefinitionTests extends TestCase {
 | 
			
		|||
		bd.getPropertyValues().add("name", "myName");
 | 
			
		||||
		bd.getPropertyValues().add("age", "99");
 | 
			
		||||
 | 
			
		||||
		ChildBeanDefinition childBd = new ChildBeanDefinition("bd");
 | 
			
		||||
		GenericBeanDefinition childBd = new GenericBeanDefinition();
 | 
			
		||||
		childBd.setParentName("bd");
 | 
			
		||||
 | 
			
		||||
		RootBeanDefinition mergedBd = new RootBeanDefinition(bd);
 | 
			
		||||
		mergedBd.overrideFrom(childBd);
 | 
			
		||||
		mergedBd.overrideFrom((BeanDefinition) childBd);
 | 
			
		||||
		assertEquals(2, mergedBd.getConstructorArgumentValues().getArgumentCount());
 | 
			
		||||
		assertEquals(2, mergedBd.getPropertyValues().size());
 | 
			
		||||
		assertEquals(bd, mergedBd);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,6 +16,13 @@
 | 
			
		|||
 | 
			
		||||
package org.springframework.beans.factory.support;
 | 
			
		||||
 | 
			
		||||
import static org.junit.Assert.assertEquals;
 | 
			
		||||
import static org.junit.Assert.assertNotSame;
 | 
			
		||||
import static org.junit.Assert.assertNull;
 | 
			
		||||
import static org.junit.Assert.assertSame;
 | 
			
		||||
import static org.junit.Assert.assertTrue;
 | 
			
		||||
import static org.junit.Assert.fail;
 | 
			
		||||
 | 
			
		||||
import java.net.MalformedURLException;
 | 
			
		||||
import java.net.URI;
 | 
			
		||||
import java.net.URL;
 | 
			
		||||
| 
						 | 
				
			
			@ -28,24 +35,21 @@ import java.util.List;
 | 
			
		|||
import java.util.Map;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
import static org.junit.Assert.*;
 | 
			
		||||
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import org.mockito.Mockito;
 | 
			
		||||
import org.springframework.beans.PropertyEditorRegistrar;
 | 
			
		||||
import org.springframework.beans.PropertyEditorRegistry;
 | 
			
		||||
import org.springframework.beans.factory.BeanCreationException;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 | 
			
		||||
import org.springframework.beans.propertyeditors.CustomNumberEditor;
 | 
			
		||||
import org.springframework.core.io.ClassPathResource;
 | 
			
		||||
import org.springframework.core.io.UrlResource;
 | 
			
		||||
 | 
			
		||||
import test.beans.GenericBean;
 | 
			
		||||
import test.beans.GenericIntegerBean;
 | 
			
		||||
import test.beans.GenericSetOfIntegerBean;
 | 
			
		||||
import test.beans.TestBean;
 | 
			
		||||
 | 
			
		||||
import org.springframework.beans.PropertyEditorRegistrar;
 | 
			
		||||
import org.springframework.beans.PropertyEditorRegistry;
 | 
			
		||||
import org.springframework.beans.factory.BeanCreationException;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
 | 
			
		||||
import org.springframework.beans.propertyeditors.CustomNumberEditor;
 | 
			
		||||
import org.springframework.core.io.ClassPathResource;
 | 
			
		||||
import org.springframework.core.io.UrlResource;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Juergen Hoeller
 | 
			
		||||
 * @author Chris Beams
 | 
			
		||||
| 
						 | 
				
			
			@ -94,7 +98,8 @@ public class BeanFactoryGenericsTests {
 | 
			
		|||
		bf.registerSingleton("resource1", new UrlResource("http://localhost:8080"));
 | 
			
		||||
		bf.registerSingleton("resource2", new UrlResource("http://localhost:9090"));
 | 
			
		||||
 | 
			
		||||
		RootBeanDefinition rbd = new RootBeanDefinition(GenericIntegerBean.class, RootBeanDefinition.AUTOWIRE_BY_TYPE);
 | 
			
		||||
		RootBeanDefinition rbd = new RootBeanDefinition(GenericIntegerBean.class);
 | 
			
		||||
		rbd.setAutowireMode(RootBeanDefinition.AUTOWIRE_BY_TYPE);
 | 
			
		||||
		bf.registerBeanDefinition("genericBean", rbd);
 | 
			
		||||
		GenericIntegerBean gb = (GenericIntegerBean) bf.getBean("genericBean");
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -126,7 +131,8 @@ public class BeanFactoryGenericsTests {
 | 
			
		|||
	public void testGenericListPropertyWithOptionalAutowiring() throws MalformedURLException {
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
 | 
			
		||||
		RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class, RootBeanDefinition.AUTOWIRE_BY_TYPE);
 | 
			
		||||
		RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
 | 
			
		||||
		rbd.setAutowireMode(RootBeanDefinition.AUTOWIRE_BY_TYPE);
 | 
			
		||||
		bf.registerBeanDefinition("genericBean", rbd);
 | 
			
		||||
		GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean");
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -152,7 +158,9 @@ public class BeanFactoryGenericsTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testGenericListOfArraysProperty() throws MalformedURLException {
 | 
			
		||||
		XmlBeanFactory bf = new XmlBeanFactory(new ClassPathResource("genericBeanTests.xml", getClass()));
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
 | 
			
		||||
				new ClassPathResource("genericBeanTests.xml", getClass()));
 | 
			
		||||
		GenericBean<?> gb = (GenericBean<?>) bf.getBean("listOfArrays");
 | 
			
		||||
 | 
			
		||||
		assertEquals(1, gb.getListOfArrays().size());
 | 
			
		||||
| 
						 | 
				
			
			@ -186,7 +194,8 @@ public class BeanFactoryGenericsTests {
 | 
			
		|||
		bf.registerSingleton("integer1", new Integer(4));
 | 
			
		||||
		bf.registerSingleton("integer2", new Integer(5));
 | 
			
		||||
 | 
			
		||||
		RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class, RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
 | 
			
		||||
		RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
 | 
			
		||||
		rbd.setAutowireMode(RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
 | 
			
		||||
		bf.registerBeanDefinition("genericBean", rbd);
 | 
			
		||||
		GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean");
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -198,7 +207,8 @@ public class BeanFactoryGenericsTests {
 | 
			
		|||
	public void testGenericSetConstructorWithOptionalAutowiring() {
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
 | 
			
		||||
		RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class, RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
 | 
			
		||||
		RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
 | 
			
		||||
		rbd.setAutowireMode(RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
 | 
			
		||||
		bf.registerBeanDefinition("genericBean", rbd);
 | 
			
		||||
		GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean");
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -236,7 +246,8 @@ public class BeanFactoryGenericsTests {
 | 
			
		|||
		bf.registerSingleton("resource1", new UrlResource("http://localhost:8080"));
 | 
			
		||||
		bf.registerSingleton("resource2", new UrlResource("http://localhost:9090"));
 | 
			
		||||
 | 
			
		||||
		RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class, RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
 | 
			
		||||
		RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
 | 
			
		||||
		rbd.setAutowireMode(RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
 | 
			
		||||
		bf.registerBeanDefinition("genericBean", rbd);
 | 
			
		||||
		GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean");
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -252,7 +263,8 @@ public class BeanFactoryGenericsTests {
 | 
			
		|||
		bf.registerSingleton("resource1", new UrlResource("http://localhost:8080"));
 | 
			
		||||
		bf.registerSingleton("resource2", new UrlResource("http://localhost:9090"));
 | 
			
		||||
 | 
			
		||||
		RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class, RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
 | 
			
		||||
		RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
 | 
			
		||||
		rbd.setAutowireMode(RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
 | 
			
		||||
		bf.registerBeanDefinition("genericBean", rbd);
 | 
			
		||||
		GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean");
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -576,7 +588,9 @@ public class BeanFactoryGenericsTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testGenericListBean() throws Exception {
 | 
			
		||||
		XmlBeanFactory bf = new XmlBeanFactory(new ClassPathResource("genericBeanTests.xml", getClass()));
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
 | 
			
		||||
				new ClassPathResource("genericBeanTests.xml", getClass()));
 | 
			
		||||
		List<?> list = (List<?>) bf.getBean("list");
 | 
			
		||||
		assertEquals(1, list.size());
 | 
			
		||||
		assertEquals(new URL("http://localhost:8080"), list.get(0));
 | 
			
		||||
| 
						 | 
				
			
			@ -584,7 +598,9 @@ public class BeanFactoryGenericsTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testGenericSetBean() throws Exception {
 | 
			
		||||
		XmlBeanFactory bf = new XmlBeanFactory(new ClassPathResource("genericBeanTests.xml", getClass()));
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
 | 
			
		||||
				new ClassPathResource("genericBeanTests.xml", getClass()));
 | 
			
		||||
		Set<?> set = (Set<?>) bf.getBean("set");
 | 
			
		||||
		assertEquals(1, set.size());
 | 
			
		||||
		assertEquals(new URL("http://localhost:8080"), set.iterator().next());
 | 
			
		||||
| 
						 | 
				
			
			@ -592,7 +608,9 @@ public class BeanFactoryGenericsTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testGenericMapBean() throws Exception {
 | 
			
		||||
		XmlBeanFactory bf = new XmlBeanFactory(new ClassPathResource("genericBeanTests.xml", getClass()));
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
 | 
			
		||||
				new ClassPathResource("genericBeanTests.xml", getClass()));
 | 
			
		||||
		Map<?, ?> map = (Map<?, ?>) bf.getBean("map");
 | 
			
		||||
		assertEquals(1, map.size());
 | 
			
		||||
		assertEquals(new Integer(10), map.keySet().iterator().next());
 | 
			
		||||
| 
						 | 
				
			
			@ -601,7 +619,9 @@ public class BeanFactoryGenericsTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testGenericallyTypedIntegerBean() throws Exception {
 | 
			
		||||
		XmlBeanFactory bf = new XmlBeanFactory(new ClassPathResource("genericBeanTests.xml", getClass()));
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
 | 
			
		||||
				new ClassPathResource("genericBeanTests.xml", getClass()));
 | 
			
		||||
		GenericIntegerBean gb = (GenericIntegerBean) bf.getBean("integerBean");
 | 
			
		||||
		assertEquals(new Integer(10), gb.getGenericProperty());
 | 
			
		||||
		assertEquals(new Integer(20), gb.getGenericListProperty().get(0));
 | 
			
		||||
| 
						 | 
				
			
			@ -610,7 +630,9 @@ public class BeanFactoryGenericsTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testGenericallyTypedSetOfIntegerBean() throws Exception {
 | 
			
		||||
		XmlBeanFactory bf = new XmlBeanFactory(new ClassPathResource("genericBeanTests.xml", getClass()));
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
 | 
			
		||||
				new ClassPathResource("genericBeanTests.xml", getClass()));
 | 
			
		||||
		GenericSetOfIntegerBean gb = (GenericSetOfIntegerBean) bf.getBean("setOfIntegerBean");
 | 
			
		||||
		assertEquals(new Integer(10), gb.getGenericProperty().iterator().next());
 | 
			
		||||
		assertEquals(new Integer(20), gb.getGenericListProperty().get(0).iterator().next());
 | 
			
		||||
| 
						 | 
				
			
			@ -619,7 +641,9 @@ public class BeanFactoryGenericsTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testSetBean() throws Exception {
 | 
			
		||||
		XmlBeanFactory bf = new XmlBeanFactory(new ClassPathResource("genericBeanTests.xml", getClass()));
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
 | 
			
		||||
				new ClassPathResource("genericBeanTests.xml", getClass()));
 | 
			
		||||
		UrlSet us = (UrlSet) bf.getBean("setBean");
 | 
			
		||||
		assertEquals(1, us.size());
 | 
			
		||||
		assertEquals(new URL("http://www.springframework.org"), us.iterator().next());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,11 +16,11 @@
 | 
			
		|||
 | 
			
		||||
package org.springframework.beans.factory.support.security;
 | 
			
		||||
 | 
			
		||||
import static junit.framework.Assert.assertEquals;
 | 
			
		||||
import static junit.framework.Assert.assertNotNull;
 | 
			
		||||
import static junit.framework.Assert.assertNull;
 | 
			
		||||
import static junit.framework.Assert.assertTrue;
 | 
			
		||||
import static junit.framework.Assert.fail;
 | 
			
		||||
import static org.junit.Assert.assertEquals;
 | 
			
		||||
import static org.junit.Assert.assertNotNull;
 | 
			
		||||
import static org.junit.Assert.assertNull;
 | 
			
		||||
import static org.junit.Assert.assertTrue;
 | 
			
		||||
import static org.junit.Assert.fail;
 | 
			
		||||
 | 
			
		||||
import java.lang.reflect.Method;
 | 
			
		||||
import java.net.URL;
 | 
			
		||||
| 
						 | 
				
			
			@ -56,7 +56,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		|||
import org.springframework.beans.factory.support.SecurityContextProvider;
 | 
			
		||||
import org.springframework.beans.factory.support.security.support.ConstructorBean;
 | 
			
		||||
import org.springframework.beans.factory.support.security.support.CustomCallbackBean;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 | 
			
		||||
import org.springframework.core.io.DefaultResourceLoader;
 | 
			
		||||
import org.springframework.core.io.Resource;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -72,7 +72,7 @@ import org.springframework.core.io.Resource;
 | 
			
		|||
 */
 | 
			
		||||
public class CallbacksSecurityTests {
 | 
			
		||||
 | 
			
		||||
	private XmlBeanFactory beanFactory;
 | 
			
		||||
	private DefaultListableBeanFactory beanFactory;
 | 
			
		||||
	private SecurityContextProvider provider;
 | 
			
		||||
 | 
			
		||||
	private static class NonPrivilegedBean {
 | 
			
		||||
| 
						 | 
				
			
			@ -312,7 +312,8 @@ public class CallbacksSecurityTests {
 | 
			
		|||
		DefaultResourceLoader drl = new DefaultResourceLoader();
 | 
			
		||||
		Resource config = drl
 | 
			
		||||
				.getResource("/org/springframework/beans/factory/support/security/callbacks.xml");
 | 
			
		||||
		beanFactory = new XmlBeanFactory(config);
 | 
			
		||||
		beanFactory = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(beanFactory).loadBeanDefinitions(config);
 | 
			
		||||
		beanFactory.setSecurityContextProvider(provider);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,7 +20,6 @@ import java.beans.PropertyEditorSupport;
 | 
			
		|||
import java.util.StringTokenizer;
 | 
			
		||||
 | 
			
		||||
import junit.framework.TestCase;
 | 
			
		||||
import junit.framework.Assert;
 | 
			
		||||
 | 
			
		||||
import org.springframework.beans.BeansException;
 | 
			
		||||
import org.springframework.beans.PropertyBatchUpdateException;
 | 
			
		||||
| 
						 | 
				
			
			@ -88,7 +87,7 @@ public abstract class AbstractBeanFactoryTests extends TestCase {
 | 
			
		|||
	 */
 | 
			
		||||
	public void testLifecycleCallbacks() {
 | 
			
		||||
		LifecycleBean lb = (LifecycleBean) getBeanFactory().getBean("lifecycle");
 | 
			
		||||
		Assert.assertEquals("lifecycle", lb.getBeanName());
 | 
			
		||||
		assertEquals("lifecycle", lb.getBeanName());
 | 
			
		||||
		// The dummy business method will throw an exception if the
 | 
			
		||||
		// necessary callbacks weren't invoked in the right order.
 | 
			
		||||
		lb.businessMethod();
 | 
			
		||||
| 
						 | 
				
			
			@ -365,4 +364,4 @@ class MustBeInitialized implements InitializingBean {
 | 
			
		|||
			throw new RuntimeException("Factory didn't call afterPropertiesSet() on MustBeInitialized object");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright 2002-2007 the original author or authors.
 | 
			
		||||
 * 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.
 | 
			
		||||
| 
						 | 
				
			
			@ -20,8 +20,6 @@ import org.springframework.beans.factory.BeanFactory;
 | 
			
		|||
import org.springframework.beans.factory.FactoryBean;
 | 
			
		||||
import org.springframework.beans.factory.ListableBeanFactory;
 | 
			
		||||
 | 
			
		||||
import junit.framework.Assert;
 | 
			
		||||
 | 
			
		||||
import test.beans.TestBean;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			@ -48,24 +46,24 @@ public abstract class AbstractListableBeanFactoryTests extends AbstractBeanFacto
 | 
			
		|||
 | 
			
		||||
	protected final void assertCount(int count) {
 | 
			
		||||
		String[] defnames = getListableBeanFactory().getBeanDefinitionNames();
 | 
			
		||||
		Assert.assertTrue("We should have " + count + " beans, not " + defnames.length, defnames.length == count);
 | 
			
		||||
		assertTrue("We should have " + count + " beans, not " + defnames.length, defnames.length == count);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void assertTestBeanCount(int count) {
 | 
			
		||||
		String[] defNames = getListableBeanFactory().getBeanNamesForType(TestBean.class, true, false);
 | 
			
		||||
		Assert.assertTrue("We should have " + count + " beans for class org.springframework.beans.TestBean, not " +
 | 
			
		||||
		assertTrue("We should have " + count + " beans for class org.springframework.beans.TestBean, not " +
 | 
			
		||||
				defNames.length, defNames.length == count);
 | 
			
		||||
 | 
			
		||||
		int countIncludingFactoryBeans = count + 2;
 | 
			
		||||
		String[] names = getListableBeanFactory().getBeanNamesForType(TestBean.class, true, true);
 | 
			
		||||
		Assert.assertTrue("We should have " + countIncludingFactoryBeans +
 | 
			
		||||
		assertTrue("We should have " + countIncludingFactoryBeans +
 | 
			
		||||
				" beans for class org.springframework.beans.TestBean, not " + names.length,
 | 
			
		||||
				names.length == countIncludingFactoryBeans);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void testGetDefinitionsForNoSuchClass() {
 | 
			
		||||
		String[] defnames = getListableBeanFactory().getBeanNamesForType(String.class);
 | 
			
		||||
		Assert.assertTrue("No string definitions", defnames.length == 0);
 | 
			
		||||
		assertTrue("No string definitions", defnames.length == 0);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
| 
						 | 
				
			
			@ -73,18 +71,18 @@ public abstract class AbstractListableBeanFactoryTests extends AbstractBeanFacto
 | 
			
		|||
	 * what type factories may return, and it may even change over time.)
 | 
			
		||||
	 */
 | 
			
		||||
	public void testGetCountForFactoryClass() {
 | 
			
		||||
		Assert.assertTrue("Should have 2 factories, not " +
 | 
			
		||||
		assertTrue("Should have 2 factories, not " +
 | 
			
		||||
				getListableBeanFactory().getBeanNamesForType(FactoryBean.class).length,
 | 
			
		||||
				getListableBeanFactory().getBeanNamesForType(FactoryBean.class).length == 2);
 | 
			
		||||
 | 
			
		||||
		Assert.assertTrue("Should have 2 factories, not " +
 | 
			
		||||
		assertTrue("Should have 2 factories, not " +
 | 
			
		||||
				getListableBeanFactory().getBeanNamesForType(FactoryBean.class).length,
 | 
			
		||||
				getListableBeanFactory().getBeanNamesForType(FactoryBean.class).length == 2);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void testContainsBeanDefinition() {
 | 
			
		||||
		Assert.assertTrue(getListableBeanFactory().containsBeanDefinition("rod"));
 | 
			
		||||
		Assert.assertTrue(getListableBeanFactory().containsBeanDefinition("roderick"));
 | 
			
		||||
		assertTrue(getListableBeanFactory().containsBeanDefinition("rod"));
 | 
			
		||||
		assertTrue(getListableBeanFactory().containsBeanDefinition("roderick"));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright 2002-2009 the original author or authors.
 | 
			
		||||
 * 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.
 | 
			
		||||
| 
						 | 
				
			
			@ -16,9 +16,7 @@
 | 
			
		|||
 | 
			
		||||
package org.springframework.beans.factory.xml;
 | 
			
		||||
 | 
			
		||||
import junit.framework.Assert;
 | 
			
		||||
import junit.framework.TestCase;
 | 
			
		||||
import test.beans.TestBean;
 | 
			
		||||
 | 
			
		||||
import org.springframework.beans.factory.config.PropertiesFactoryBean;
 | 
			
		||||
import org.springframework.beans.factory.config.RuntimeBeanReference;
 | 
			
		||||
| 
						 | 
				
			
			@ -26,6 +24,8 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		|||
import org.springframework.beans.factory.support.RootBeanDefinition;
 | 
			
		||||
import org.springframework.core.io.ClassPathResource;
 | 
			
		||||
 | 
			
		||||
import test.beans.TestBean;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Rob Harrop
 | 
			
		||||
 * @author Juergen Hoeller
 | 
			
		||||
| 
						 | 
				
			
			@ -34,43 +34,45 @@ public class AutowireWithExclusionTests extends TestCase {
 | 
			
		|||
 | 
			
		||||
	public void testByTypeAutowireWithAutoSelfExclusion() throws Exception {
 | 
			
		||||
		CountingFactory.reset();
 | 
			
		||||
		XmlBeanFactory beanFactory = getBeanFactory("autowire-with-exclusion.xml");
 | 
			
		||||
		DefaultListableBeanFactory beanFactory = getBeanFactory("autowire-with-exclusion.xml");
 | 
			
		||||
		beanFactory.preInstantiateSingletons();
 | 
			
		||||
		TestBean rob = (TestBean) beanFactory.getBean("rob");
 | 
			
		||||
		TestBean sally = (TestBean) beanFactory.getBean("sally");
 | 
			
		||||
		assertEquals(sally, rob.getSpouse());
 | 
			
		||||
		Assert.assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
 | 
			
		||||
		assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void testByTypeAutowireWithExclusion() throws Exception {
 | 
			
		||||
		CountingFactory.reset();
 | 
			
		||||
		XmlBeanFactory beanFactory = getBeanFactory("autowire-with-exclusion.xml");
 | 
			
		||||
		DefaultListableBeanFactory beanFactory = getBeanFactory("autowire-with-exclusion.xml");
 | 
			
		||||
		beanFactory.preInstantiateSingletons();
 | 
			
		||||
		TestBean rob = (TestBean) beanFactory.getBean("rob");
 | 
			
		||||
		assertEquals("props1", rob.getSomeProperties().getProperty("name"));
 | 
			
		||||
		Assert.assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
 | 
			
		||||
		assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void testByTypeAutowireWithExclusionInParentFactory() throws Exception {
 | 
			
		||||
		CountingFactory.reset();
 | 
			
		||||
		XmlBeanFactory parent = getBeanFactory("autowire-with-exclusion.xml");
 | 
			
		||||
		DefaultListableBeanFactory parent = getBeanFactory("autowire-with-exclusion.xml");
 | 
			
		||||
		parent.preInstantiateSingletons();
 | 
			
		||||
		DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
 | 
			
		||||
		RootBeanDefinition robDef = new RootBeanDefinition(TestBean.class, RootBeanDefinition.AUTOWIRE_BY_TYPE);
 | 
			
		||||
		RootBeanDefinition robDef = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		robDef.setAutowireMode(RootBeanDefinition.AUTOWIRE_BY_TYPE);
 | 
			
		||||
		robDef.getPropertyValues().add("spouse", new RuntimeBeanReference("sally"));
 | 
			
		||||
		child.registerBeanDefinition("rob2", robDef);
 | 
			
		||||
		TestBean rob = (TestBean) child.getBean("rob2");
 | 
			
		||||
		assertEquals("props1", rob.getSomeProperties().getProperty("name"));
 | 
			
		||||
		Assert.assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
 | 
			
		||||
		assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void testByTypeAutowireWithPrimaryInParentFactory() throws Exception {
 | 
			
		||||
		CountingFactory.reset();
 | 
			
		||||
		XmlBeanFactory parent = getBeanFactory("autowire-with-exclusion.xml");
 | 
			
		||||
		DefaultListableBeanFactory parent = getBeanFactory("autowire-with-exclusion.xml");
 | 
			
		||||
		parent.getBeanDefinition("props1").setPrimary(true);
 | 
			
		||||
		parent.preInstantiateSingletons();
 | 
			
		||||
		DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
 | 
			
		||||
		RootBeanDefinition robDef = new RootBeanDefinition(TestBean.class, RootBeanDefinition.AUTOWIRE_BY_TYPE);
 | 
			
		||||
		RootBeanDefinition robDef = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		robDef.setAutowireMode(RootBeanDefinition.AUTOWIRE_BY_TYPE);
 | 
			
		||||
		robDef.getPropertyValues().add("spouse", new RuntimeBeanReference("sally"));
 | 
			
		||||
		child.registerBeanDefinition("rob2", robDef);
 | 
			
		||||
		RootBeanDefinition propsDef = new RootBeanDefinition(PropertiesFactoryBean.class);
 | 
			
		||||
| 
						 | 
				
			
			@ -78,15 +80,16 @@ public class AutowireWithExclusionTests extends TestCase {
 | 
			
		|||
		child.registerBeanDefinition("props3", propsDef);
 | 
			
		||||
		TestBean rob = (TestBean) child.getBean("rob2");
 | 
			
		||||
		assertEquals("props1", rob.getSomeProperties().getProperty("name"));
 | 
			
		||||
		Assert.assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
 | 
			
		||||
		assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void testByTypeAutowireWithPrimaryOverridingParentFactory() throws Exception {
 | 
			
		||||
		CountingFactory.reset();
 | 
			
		||||
		XmlBeanFactory parent = getBeanFactory("autowire-with-exclusion.xml");
 | 
			
		||||
		DefaultListableBeanFactory parent = getBeanFactory("autowire-with-exclusion.xml");
 | 
			
		||||
		parent.preInstantiateSingletons();
 | 
			
		||||
		DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
 | 
			
		||||
		RootBeanDefinition robDef = new RootBeanDefinition(TestBean.class, RootBeanDefinition.AUTOWIRE_BY_TYPE);
 | 
			
		||||
		RootBeanDefinition robDef = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		robDef.setAutowireMode(RootBeanDefinition.AUTOWIRE_BY_TYPE);
 | 
			
		||||
		robDef.getPropertyValues().add("spouse", new RuntimeBeanReference("sally"));
 | 
			
		||||
		child.registerBeanDefinition("rob2", robDef);
 | 
			
		||||
		RootBeanDefinition propsDef = new RootBeanDefinition(PropertiesFactoryBean.class);
 | 
			
		||||
| 
						 | 
				
			
			@ -95,16 +98,17 @@ public class AutowireWithExclusionTests extends TestCase {
 | 
			
		|||
		child.registerBeanDefinition("props3", propsDef);
 | 
			
		||||
		TestBean rob = (TestBean) child.getBean("rob2");
 | 
			
		||||
		assertEquals("props3", rob.getSomeProperties().getProperty("name"));
 | 
			
		||||
		Assert.assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
 | 
			
		||||
		assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void testByTypeAutowireWithPrimaryInParentAndChild() throws Exception {
 | 
			
		||||
		CountingFactory.reset();
 | 
			
		||||
		XmlBeanFactory parent = getBeanFactory("autowire-with-exclusion.xml");
 | 
			
		||||
		DefaultListableBeanFactory parent = getBeanFactory("autowire-with-exclusion.xml");
 | 
			
		||||
		parent.getBeanDefinition("props1").setPrimary(true);
 | 
			
		||||
		parent.preInstantiateSingletons();
 | 
			
		||||
		DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
 | 
			
		||||
		RootBeanDefinition robDef = new RootBeanDefinition(TestBean.class, RootBeanDefinition.AUTOWIRE_BY_TYPE);
 | 
			
		||||
		RootBeanDefinition robDef = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		robDef.setAutowireMode(RootBeanDefinition.AUTOWIRE_BY_TYPE);
 | 
			
		||||
		robDef.getPropertyValues().add("spouse", new RuntimeBeanReference("sally"));
 | 
			
		||||
		child.registerBeanDefinition("rob2", robDef);
 | 
			
		||||
		RootBeanDefinition propsDef = new RootBeanDefinition(PropertiesFactoryBean.class);
 | 
			
		||||
| 
						 | 
				
			
			@ -113,29 +117,29 @@ public class AutowireWithExclusionTests extends TestCase {
 | 
			
		|||
		child.registerBeanDefinition("props3", propsDef);
 | 
			
		||||
		TestBean rob = (TestBean) child.getBean("rob2");
 | 
			
		||||
		assertEquals("props3", rob.getSomeProperties().getProperty("name"));
 | 
			
		||||
		Assert.assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
 | 
			
		||||
		assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void testByTypeAutowireWithInclusion() throws Exception {
 | 
			
		||||
		CountingFactory.reset();
 | 
			
		||||
		XmlBeanFactory beanFactory = getBeanFactory("autowire-with-inclusion.xml");
 | 
			
		||||
		DefaultListableBeanFactory beanFactory = getBeanFactory("autowire-with-inclusion.xml");
 | 
			
		||||
		beanFactory.preInstantiateSingletons();
 | 
			
		||||
		TestBean rob = (TestBean) beanFactory.getBean("rob");
 | 
			
		||||
		assertEquals("props1", rob.getSomeProperties().getProperty("name"));
 | 
			
		||||
		Assert.assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
 | 
			
		||||
		assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void testByTypeAutowireWithSelectiveInclusion() throws Exception {
 | 
			
		||||
		CountingFactory.reset();
 | 
			
		||||
		XmlBeanFactory beanFactory = getBeanFactory("autowire-with-selective-inclusion.xml");
 | 
			
		||||
		DefaultListableBeanFactory beanFactory = getBeanFactory("autowire-with-selective-inclusion.xml");
 | 
			
		||||
		beanFactory.preInstantiateSingletons();
 | 
			
		||||
		TestBean rob = (TestBean) beanFactory.getBean("rob");
 | 
			
		||||
		assertEquals("props1", rob.getSomeProperties().getProperty("name"));
 | 
			
		||||
		Assert.assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
 | 
			
		||||
		assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void testConstructorAutowireWithAutoSelfExclusion() throws Exception {
 | 
			
		||||
		XmlBeanFactory beanFactory = getBeanFactory("autowire-constructor-with-exclusion.xml");
 | 
			
		||||
		DefaultListableBeanFactory beanFactory = getBeanFactory("autowire-constructor-with-exclusion.xml");
 | 
			
		||||
		TestBean rob = (TestBean) beanFactory.getBean("rob");
 | 
			
		||||
		TestBean sally = (TestBean) beanFactory.getBean("sally");
 | 
			
		||||
		assertEquals(sally, rob.getSpouse());
 | 
			
		||||
| 
						 | 
				
			
			@ -147,13 +151,16 @@ public class AutowireWithExclusionTests extends TestCase {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public void testConstructorAutowireWithExclusion() throws Exception {
 | 
			
		||||
		XmlBeanFactory beanFactory = getBeanFactory("autowire-constructor-with-exclusion.xml");
 | 
			
		||||
		DefaultListableBeanFactory beanFactory = getBeanFactory("autowire-constructor-with-exclusion.xml");
 | 
			
		||||
		TestBean rob = (TestBean) beanFactory.getBean("rob");
 | 
			
		||||
		assertEquals("props1", rob.getSomeProperties().getProperty("name"));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private XmlBeanFactory getBeanFactory(String configPath) {
 | 
			
		||||
		return new XmlBeanFactory(new ClassPathResource(configPath, getClass()));
 | 
			
		||||
	private DefaultListableBeanFactory getBeanFactory(String configPath) {
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
 | 
			
		||||
				new ClassPathResource(configPath, getClass()));
 | 
			
		||||
		return bf;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,6 +19,7 @@ package org.springframework.beans.factory.xml;
 | 
			
		|||
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;
 | 
			
		||||
| 
						 | 
				
			
			@ -38,9 +39,9 @@ public class CollectingReaderEventListener implements ReaderEventListener {
 | 
			
		|||
 | 
			
		||||
	private final List defaults = new LinkedList();
 | 
			
		||||
 | 
			
		||||
	private final Map componentDefinitions = CollectionFactory.createLinkedMapIfPossible(8);
 | 
			
		||||
	private final Map componentDefinitions = new LinkedHashMap<>(8);
 | 
			
		||||
 | 
			
		||||
	private final Map aliasMap = CollectionFactory.createLinkedMapIfPossible(8);
 | 
			
		||||
	private final Map aliasMap = new LinkedHashMap<>(8);
 | 
			
		||||
 | 
			
		||||
	private final List imports = new LinkedList();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -92,4 +93,4 @@ public class CollectingReaderEventListener implements ReaderEventListener {
 | 
			
		|||
		return Collections.unmodifiableList(this.imports);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright 2002-2009 the original author or authors.
 | 
			
		||||
 * 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.
 | 
			
		||||
| 
						 | 
				
			
			@ -16,25 +16,30 @@
 | 
			
		|||
 | 
			
		||||
package org.springframework.beans.factory.xml;
 | 
			
		||||
 | 
			
		||||
import static org.junit.Assert.assertEquals;
 | 
			
		||||
import static org.junit.Assert.assertTrue;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
import static org.junit.Assert.*;
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import test.beans.TestBean;
 | 
			
		||||
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.core.io.ClassPathResource;
 | 
			
		||||
 | 
			
		||||
import test.beans.TestBean;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Rob Harrop
 | 
			
		||||
 * @author Juergen Hoeller
 | 
			
		||||
 */
 | 
			
		||||
public class CollectionsWithDefaultTypesTests {
 | 
			
		||||
 | 
			
		||||
	private final XmlBeanFactory beanFactory;
 | 
			
		||||
	private final DefaultListableBeanFactory beanFactory;
 | 
			
		||||
 | 
			
		||||
	public CollectionsWithDefaultTypesTests() {
 | 
			
		||||
		this.beanFactory = new XmlBeanFactory(new ClassPathResource("collectionsWithDefaultTypes.xml", getClass()));
 | 
			
		||||
		this.beanFactory = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(
 | 
			
		||||
				new ClassPathResource("collectionsWithDefaultTypes.xml", getClass()));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Test
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,6 +18,7 @@ package org.springframework.beans.factory.xml;
 | 
			
		|||
 | 
			
		||||
import junit.framework.TestCase;
 | 
			
		||||
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.core.io.ClassPathResource;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			@ -25,11 +26,13 @@ import org.springframework.core.io.ClassPathResource;
 | 
			
		|||
 */
 | 
			
		||||
public class DefaultLifecycleMethodsTests extends TestCase {
 | 
			
		||||
 | 
			
		||||
	private XmlBeanFactory beanFactory;
 | 
			
		||||
	private DefaultListableBeanFactory beanFactory;
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	protected void setUp() throws Exception {
 | 
			
		||||
		this.beanFactory = new XmlBeanFactory(new ClassPathResource("defaultLifecycleMethods.xml", getClass()));
 | 
			
		||||
		this.beanFactory = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(new ClassPathResource(
 | 
			
		||||
				"defaultLifecycleMethods.xml", getClass()));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void testLifecycleMethodsInvoked() {
 | 
			
		||||
| 
						 | 
				
			
			@ -49,7 +52,9 @@ public class DefaultLifecycleMethodsTests extends TestCase {
 | 
			
		|||
 | 
			
		||||
	public void testIgnoreDefaultLifecycleMethods() throws Exception {
 | 
			
		||||
		try {
 | 
			
		||||
			XmlBeanFactory bf = new XmlBeanFactory(new ClassPathResource("ignoreDefaultLifecycleMethods.xml", getClass()));
 | 
			
		||||
			DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
			new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
 | 
			
		||||
					new ClassPathResource("ignoreDefaultLifecycleMethods.xml", getClass()));
 | 
			
		||||
			bf.preInstantiateSingletons();
 | 
			
		||||
			bf.destroySingletons();
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,6 +20,7 @@ import junit.framework.TestCase;
 | 
			
		|||
 | 
			
		||||
import org.springframework.beans.PropertyValue;
 | 
			
		||||
import org.springframework.beans.factory.config.BeanDefinition;
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.core.io.ClassPathResource;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			@ -27,11 +28,13 @@ import org.springframework.core.io.ClassPathResource;
 | 
			
		|||
 */
 | 
			
		||||
public class MetadataAttachmentTests extends TestCase {
 | 
			
		||||
 | 
			
		||||
	private XmlBeanFactory beanFactory;
 | 
			
		||||
	private DefaultListableBeanFactory beanFactory;
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	protected void setUp() throws Exception {
 | 
			
		||||
		this.beanFactory = new XmlBeanFactory(new ClassPathResource("withMeta.xml", getClass()));
 | 
			
		||||
		this.beanFactory = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(
 | 
			
		||||
				new ClassPathResource("withMeta.xml", getClass()));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void testMetadataAttachment() throws Exception {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,8 +21,8 @@ import static org.junit.Assert.assertThat;
 | 
			
		|||
 | 
			
		||||
import org.hamcrest.Description;
 | 
			
		||||
import org.hamcrest.Matcher;
 | 
			
		||||
import org.hamcrest.TypeSafeMatcher;
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import org.junit.internal.matchers.TypeSafeMatcher;
 | 
			
		||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.core.env.ConfigurableEnvironment;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals;
 | 
			
		|||
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.core.io.ClassPathResource;
 | 
			
		||||
 | 
			
		||||
import test.beans.DummyBean;
 | 
			
		||||
| 
						 | 
				
			
			@ -32,7 +33,7 @@ public class SimpleConstructorNamespaceHandlerTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void simpleValue() throws Exception {
 | 
			
		||||
		XmlBeanFactory beanFactory = createFactory("simpleConstructorNamespaceHandlerTests.xml");
 | 
			
		||||
		DefaultListableBeanFactory beanFactory = createFactory("simpleConstructorNamespaceHandlerTests.xml");
 | 
			
		||||
		String name = "simple";
 | 
			
		||||
		//		beanFactory.getBean("simple1", DummyBean.class);
 | 
			
		||||
		DummyBean nameValue = beanFactory.getBean(name, DummyBean.class);
 | 
			
		||||
| 
						 | 
				
			
			@ -41,7 +42,7 @@ public class SimpleConstructorNamespaceHandlerTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void simpleRef() throws Exception {
 | 
			
		||||
		XmlBeanFactory beanFactory = createFactory("simpleConstructorNamespaceHandlerTests.xml");
 | 
			
		||||
		DefaultListableBeanFactory beanFactory = createFactory("simpleConstructorNamespaceHandlerTests.xml");
 | 
			
		||||
		String name = "simple-ref";
 | 
			
		||||
		//		beanFactory.getBean("name-value1", TestBean.class);
 | 
			
		||||
		DummyBean nameValue = beanFactory.getBean(name, DummyBean.class);
 | 
			
		||||
| 
						 | 
				
			
			@ -50,7 +51,7 @@ public class SimpleConstructorNamespaceHandlerTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void nameValue() throws Exception {
 | 
			
		||||
		XmlBeanFactory beanFactory = createFactory("simpleConstructorNamespaceHandlerTests.xml");
 | 
			
		||||
		DefaultListableBeanFactory beanFactory = createFactory("simpleConstructorNamespaceHandlerTests.xml");
 | 
			
		||||
		String name = "name-value";
 | 
			
		||||
		//		beanFactory.getBean("name-value1", TestBean.class);
 | 
			
		||||
		TestBean nameValue = beanFactory.getBean(name, TestBean.class);
 | 
			
		||||
| 
						 | 
				
			
			@ -60,7 +61,7 @@ public class SimpleConstructorNamespaceHandlerTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void nameRef() throws Exception {
 | 
			
		||||
		XmlBeanFactory beanFactory = createFactory("simpleConstructorNamespaceHandlerTests.xml");
 | 
			
		||||
		DefaultListableBeanFactory beanFactory = createFactory("simpleConstructorNamespaceHandlerTests.xml");
 | 
			
		||||
		TestBean nameValue = beanFactory.getBean("name-value", TestBean.class);
 | 
			
		||||
		DummyBean nameRef = beanFactory.getBean("name-ref", DummyBean.class);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -70,7 +71,7 @@ public class SimpleConstructorNamespaceHandlerTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void typeIndexedValue() throws Exception {
 | 
			
		||||
		XmlBeanFactory beanFactory = createFactory("simpleConstructorNamespaceHandlerTests.xml");
 | 
			
		||||
		DefaultListableBeanFactory beanFactory = createFactory("simpleConstructorNamespaceHandlerTests.xml");
 | 
			
		||||
		DummyBean typeRef = beanFactory.getBean("indexed-value", DummyBean.class);
 | 
			
		||||
 | 
			
		||||
		assertEquals("at", typeRef.getName());
 | 
			
		||||
| 
						 | 
				
			
			@ -80,7 +81,7 @@ public class SimpleConstructorNamespaceHandlerTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void typeIndexedRef() throws Exception {
 | 
			
		||||
		XmlBeanFactory beanFactory = createFactory("simpleConstructorNamespaceHandlerTests.xml");
 | 
			
		||||
		DefaultListableBeanFactory beanFactory = createFactory("simpleConstructorNamespaceHandlerTests.xml");
 | 
			
		||||
		DummyBean typeRef = beanFactory.getBean("indexed-ref", DummyBean.class);
 | 
			
		||||
 | 
			
		||||
		assertEquals("some-name", typeRef.getName());
 | 
			
		||||
| 
						 | 
				
			
			@ -89,20 +90,23 @@ public class SimpleConstructorNamespaceHandlerTests {
 | 
			
		|||
 | 
			
		||||
	@Test(expected = BeanDefinitionStoreException.class)
 | 
			
		||||
	public void ambiguousConstructor() throws Exception {
 | 
			
		||||
		new XmlBeanFactory(new ClassPathResource("simpleConstructorNamespaceHandlerTestsWithErrors.xml", getClass()));
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
 | 
			
		||||
				new ClassPathResource("simpleConstructorNamespaceHandlerTestsWithErrors.xml", getClass()));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void constructorWithNameEndingInRef() throws Exception {
 | 
			
		||||
		XmlBeanFactory beanFactory = createFactory("simpleConstructorNamespaceHandlerTests.xml");
 | 
			
		||||
		DefaultListableBeanFactory beanFactory = createFactory("simpleConstructorNamespaceHandlerTests.xml");
 | 
			
		||||
		DummyBean derivedBean = beanFactory.getBean("beanWithRefConstructorArg", DummyBean.class);
 | 
			
		||||
		assertEquals(10, derivedBean.getAge());
 | 
			
		||||
		assertEquals("silly name", derivedBean.getName());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private XmlBeanFactory createFactory(String resourceName) {
 | 
			
		||||
		XmlBeanFactory fact = new XmlBeanFactory(new ClassPathResource(resourceName, getClass()));
 | 
			
		||||
		//fact.setParameterNameDiscoverer(new LocalVariableTableParameterNameDiscoverer());
 | 
			
		||||
		return fact;
 | 
			
		||||
	private DefaultListableBeanFactory createFactory(String resourceName) {
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
 | 
			
		||||
				new ClassPathResource(resourceName, getClass()));
 | 
			
		||||
		return bf;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright 2002-2007 the original author or authors.
 | 
			
		||||
 * 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.
 | 
			
		||||
| 
						 | 
				
			
			@ -17,13 +17,15 @@
 | 
			
		|||
package org.springframework.beans.factory.xml;
 | 
			
		||||
 | 
			
		||||
import static org.junit.Assert.assertEquals;
 | 
			
		||||
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.core.io.ClassPathResource;
 | 
			
		||||
 | 
			
		||||
import test.beans.ITestBean;
 | 
			
		||||
import test.beans.TestBean;
 | 
			
		||||
 | 
			
		||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
 | 
			
		||||
import org.springframework.core.io.ClassPathResource;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Rob Harrop
 | 
			
		||||
 * @author Juergen Hoeller
 | 
			
		||||
| 
						 | 
				
			
			@ -33,8 +35,9 @@ public class SimplePropertyNamespaceHandlerTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void simpleBeanConfigured() throws Exception {
 | 
			
		||||
		XmlBeanFactory beanFactory =
 | 
			
		||||
				new XmlBeanFactory(new ClassPathResource("simplePropertyNamespaceHandlerTests.xml", getClass()));
 | 
			
		||||
		DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(beanFactory).loadBeanDefinitions(
 | 
			
		||||
				new ClassPathResource("simplePropertyNamespaceHandlerTests.xml", getClass()));
 | 
			
		||||
		ITestBean rob = (TestBean) beanFactory.getBean("rob");
 | 
			
		||||
		ITestBean sally = (TestBean) beanFactory.getBean("sally");
 | 
			
		||||
		assertEquals("Rob Harrop", rob.getName());
 | 
			
		||||
| 
						 | 
				
			
			@ -44,8 +47,9 @@ public class SimplePropertyNamespaceHandlerTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void innerBeanConfigured() throws Exception {
 | 
			
		||||
		XmlBeanFactory beanFactory =
 | 
			
		||||
				new XmlBeanFactory(new ClassPathResource("simplePropertyNamespaceHandlerTests.xml", getClass()));
 | 
			
		||||
		DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(beanFactory).loadBeanDefinitions(
 | 
			
		||||
				new ClassPathResource("simplePropertyNamespaceHandlerTests.xml", getClass()));
 | 
			
		||||
		TestBean sally = (TestBean) beanFactory.getBean("sally2");
 | 
			
		||||
		ITestBean rob = sally.getSpouse();
 | 
			
		||||
		assertEquals("Rob Harrop", rob.getName());
 | 
			
		||||
| 
						 | 
				
			
			@ -55,13 +59,16 @@ public class SimplePropertyNamespaceHandlerTests {
 | 
			
		|||
 | 
			
		||||
	@Test(expected = BeanDefinitionStoreException.class)
 | 
			
		||||
	public void withPropertyDefinedTwice() throws Exception {
 | 
			
		||||
		new XmlBeanFactory(new ClassPathResource("simplePropertyNamespaceHandlerTestsWithErrors.xml", getClass()));
 | 
			
		||||
		DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(beanFactory).loadBeanDefinitions(
 | 
			
		||||
				new ClassPathResource("simplePropertyNamespaceHandlerTestsWithErrors.xml", getClass()));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void propertyWithNameEndingInRef() throws Exception {
 | 
			
		||||
		XmlBeanFactory beanFactory =
 | 
			
		||||
				new XmlBeanFactory(new ClassPathResource("simplePropertyNamespaceHandlerTests.xml", getClass()));
 | 
			
		||||
		DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(beanFactory).loadBeanDefinitions(
 | 
			
		||||
				new ClassPathResource("simplePropertyNamespaceHandlerTests.xml", getClass()));
 | 
			
		||||
		ITestBean sally = (TestBean) beanFactory.getBean("derivedSally");
 | 
			
		||||
		assertEquals("r", sally.getSpouse().getName());
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,7 +16,14 @@
 | 
			
		|||
 | 
			
		||||
package org.springframework.beans.factory.xml;
 | 
			
		||||
 | 
			
		||||
import static org.junit.Assert.assertEquals;
 | 
			
		||||
import static org.junit.Assert.assertNotNull;
 | 
			
		||||
import static org.junit.Assert.assertTrue;
 | 
			
		||||
import static org.junit.Assert.fail;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
import java.util.IdentityHashMap;
 | 
			
		||||
import java.util.Iterator;
 | 
			
		||||
import java.util.LinkedHashMap;
 | 
			
		||||
import java.util.LinkedHashSet;
 | 
			
		||||
| 
						 | 
				
			
			@ -27,21 +34,19 @@ import java.util.Properties;
 | 
			
		|||
import java.util.Set;
 | 
			
		||||
import java.util.TreeMap;
 | 
			
		||||
import java.util.TreeSet;
 | 
			
		||||
import java.util.IdentityHashMap;
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
import java.util.concurrent.CopyOnWriteArraySet;
 | 
			
		||||
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import static org.junit.Assert.*;
 | 
			
		||||
import test.beans.TestBean;
 | 
			
		||||
 | 
			
		||||
import org.springframework.beans.factory.BeanCreationException;
 | 
			
		||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
 | 
			
		||||
import org.springframework.beans.factory.config.ListFactoryBean;
 | 
			
		||||
import org.springframework.beans.factory.config.MapFactoryBean;
 | 
			
		||||
import org.springframework.beans.factory.config.SetFactoryBean;
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.core.io.ClassPathResource;
 | 
			
		||||
 | 
			
		||||
import test.beans.TestBean;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Tests for collections in XML bean definitions.
 | 
			
		||||
 *
 | 
			
		||||
| 
						 | 
				
			
			@ -51,10 +56,12 @@ import org.springframework.core.io.ClassPathResource;
 | 
			
		|||
 */
 | 
			
		||||
public class XmlBeanCollectionTests {
 | 
			
		||||
 | 
			
		||||
	private final XmlBeanFactory beanFactory;
 | 
			
		||||
	private final DefaultListableBeanFactory beanFactory;
 | 
			
		||||
 | 
			
		||||
	public XmlBeanCollectionTests() {
 | 
			
		||||
		this.beanFactory = new XmlBeanFactory(new ClassPathResource("collections.xml", getClass()));
 | 
			
		||||
		this.beanFactory = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(
 | 
			
		||||
				new ClassPathResource("collections.xml", getClass()));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Test
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,8 +21,6 @@ import java.util.HashMap;
 | 
			
		|||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
import junit.framework.Assert;
 | 
			
		||||
 | 
			
		||||
import org.springframework.beans.BeansException;
 | 
			
		||||
import org.springframework.beans.MutablePropertyValues;
 | 
			
		||||
import org.springframework.beans.factory.BeanFactory;
 | 
			
		||||
| 
						 | 
				
			
			@ -44,21 +42,25 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest
 | 
			
		|||
 | 
			
		||||
	private DefaultListableBeanFactory parent;
 | 
			
		||||
 | 
			
		||||
	private XmlBeanFactory factory;
 | 
			
		||||
	private DefaultListableBeanFactory factory;
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	protected void setUp() {
 | 
			
		||||
		parent = new DefaultListableBeanFactory();
 | 
			
		||||
		Map m = new HashMap();
 | 
			
		||||
		m.put("name", "Albert");
 | 
			
		||||
		parent.registerBeanDefinition("father",
 | 
			
		||||
			new RootBeanDefinition(TestBean.class, new MutablePropertyValues(m)));
 | 
			
		||||
		RootBeanDefinition bd1 = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		bd1.setPropertyValues(new MutablePropertyValues(m));
 | 
			
		||||
		parent.registerBeanDefinition("father", bd1);
 | 
			
		||||
		m = new HashMap();
 | 
			
		||||
		m.put("name", "Roderick");
 | 
			
		||||
		parent.registerBeanDefinition("rod",
 | 
			
		||||
			new RootBeanDefinition(TestBean.class, new MutablePropertyValues(m)));
 | 
			
		||||
		RootBeanDefinition bd2 = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		bd2.setPropertyValues(new MutablePropertyValues(m));
 | 
			
		||||
		parent.registerBeanDefinition("rod", bd2);
 | 
			
		||||
 | 
			
		||||
		this.factory = new XmlBeanFactory(new ClassPathResource("test.xml", getClass()), parent);
 | 
			
		||||
		this.factory = new DefaultListableBeanFactory(parent);
 | 
			
		||||
		new XmlBeanDefinitionReader(this.factory).loadBeanDefinitions(
 | 
			
		||||
				new ClassPathResource("test.xml", getClass()));
 | 
			
		||||
		this.factory.addBeanPostProcessor(new BeanPostProcessor() {
 | 
			
		||||
			@Override
 | 
			
		||||
			public Object postProcessBeforeInitialization(Object bean, String name) throws BeansException {
 | 
			
		||||
| 
						 | 
				
			
			@ -106,7 +108,7 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest
 | 
			
		|||
 | 
			
		||||
	public void testDescriptionButNoProperties() throws Exception {
 | 
			
		||||
		TestBean validEmpty = (TestBean) getBeanFactory().getBean("validEmptyWithDescription");
 | 
			
		||||
		Assert.assertEquals(0, validEmpty.getAge());
 | 
			
		||||
		assertEquals(0, validEmpty.getAge());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
| 
						 | 
				
			
			@ -117,94 +119,94 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest
 | 
			
		|||
 | 
			
		||||
		TestBean tb1 = (TestBean) getBeanFactory().getBean("aliased");
 | 
			
		||||
		TestBean alias1 = (TestBean) getBeanFactory().getBean("myalias");
 | 
			
		||||
		Assert.assertTrue(tb1 == alias1);
 | 
			
		||||
		assertTrue(tb1 == alias1);
 | 
			
		||||
		List tb1Aliases = Arrays.asList(getBeanFactory().getAliases("aliased"));
 | 
			
		||||
		Assert.assertEquals(2, tb1Aliases.size());
 | 
			
		||||
		Assert.assertTrue(tb1Aliases.contains("myalias"));
 | 
			
		||||
		Assert.assertTrue(tb1Aliases.contains("youralias"));
 | 
			
		||||
		Assert.assertTrue(beanNames.contains("aliased"));
 | 
			
		||||
		Assert.assertFalse(beanNames.contains("myalias"));
 | 
			
		||||
		Assert.assertFalse(beanNames.contains("youralias"));
 | 
			
		||||
		assertEquals(2, tb1Aliases.size());
 | 
			
		||||
		assertTrue(tb1Aliases.contains("myalias"));
 | 
			
		||||
		assertTrue(tb1Aliases.contains("youralias"));
 | 
			
		||||
		assertTrue(beanNames.contains("aliased"));
 | 
			
		||||
		assertFalse(beanNames.contains("myalias"));
 | 
			
		||||
		assertFalse(beanNames.contains("youralias"));
 | 
			
		||||
 | 
			
		||||
		TestBean tb2 = (TestBean) getBeanFactory().getBean("multiAliased");
 | 
			
		||||
		TestBean alias2 = (TestBean) getBeanFactory().getBean("alias1");
 | 
			
		||||
		TestBean alias3 = (TestBean) getBeanFactory().getBean("alias2");
 | 
			
		||||
		TestBean alias3a = (TestBean) getBeanFactory().getBean("alias3");
 | 
			
		||||
		TestBean alias3b = (TestBean) getBeanFactory().getBean("alias4");
 | 
			
		||||
		Assert.assertTrue(tb2 == alias2);
 | 
			
		||||
		Assert.assertTrue(tb2 == alias3);
 | 
			
		||||
		Assert.assertTrue(tb2 == alias3a);
 | 
			
		||||
		Assert.assertTrue(tb2 == alias3b);
 | 
			
		||||
		assertTrue(tb2 == alias2);
 | 
			
		||||
		assertTrue(tb2 == alias3);
 | 
			
		||||
		assertTrue(tb2 == alias3a);
 | 
			
		||||
		assertTrue(tb2 == alias3b);
 | 
			
		||||
 | 
			
		||||
		List tb2Aliases = Arrays.asList(getBeanFactory().getAliases("multiAliased"));
 | 
			
		||||
		Assert.assertEquals(4, tb2Aliases.size());
 | 
			
		||||
		Assert.assertTrue(tb2Aliases.contains("alias1"));
 | 
			
		||||
		Assert.assertTrue(tb2Aliases.contains("alias2"));
 | 
			
		||||
		Assert.assertTrue(tb2Aliases.contains("alias3"));
 | 
			
		||||
		Assert.assertTrue(tb2Aliases.contains("alias4"));
 | 
			
		||||
		Assert.assertTrue(beanNames.contains("multiAliased"));
 | 
			
		||||
		Assert.assertFalse(beanNames.contains("alias1"));
 | 
			
		||||
		Assert.assertFalse(beanNames.contains("alias2"));
 | 
			
		||||
		Assert.assertFalse(beanNames.contains("alias3"));
 | 
			
		||||
		Assert.assertFalse(beanNames.contains("alias4"));
 | 
			
		||||
		assertEquals(4, tb2Aliases.size());
 | 
			
		||||
		assertTrue(tb2Aliases.contains("alias1"));
 | 
			
		||||
		assertTrue(tb2Aliases.contains("alias2"));
 | 
			
		||||
		assertTrue(tb2Aliases.contains("alias3"));
 | 
			
		||||
		assertTrue(tb2Aliases.contains("alias4"));
 | 
			
		||||
		assertTrue(beanNames.contains("multiAliased"));
 | 
			
		||||
		assertFalse(beanNames.contains("alias1"));
 | 
			
		||||
		assertFalse(beanNames.contains("alias2"));
 | 
			
		||||
		assertFalse(beanNames.contains("alias3"));
 | 
			
		||||
		assertFalse(beanNames.contains("alias4"));
 | 
			
		||||
 | 
			
		||||
		TestBean tb3 = (TestBean) getBeanFactory().getBean("aliasWithoutId1");
 | 
			
		||||
		TestBean alias4 = (TestBean) getBeanFactory().getBean("aliasWithoutId2");
 | 
			
		||||
		TestBean alias5 = (TestBean) getBeanFactory().getBean("aliasWithoutId3");
 | 
			
		||||
		Assert.assertTrue(tb3 == alias4);
 | 
			
		||||
		Assert.assertTrue(tb3 == alias5);
 | 
			
		||||
		assertTrue(tb3 == alias4);
 | 
			
		||||
		assertTrue(tb3 == alias5);
 | 
			
		||||
		List tb3Aliases = Arrays.asList(getBeanFactory().getAliases("aliasWithoutId1"));
 | 
			
		||||
		Assert.assertEquals(2, tb3Aliases.size());
 | 
			
		||||
		Assert.assertTrue(tb3Aliases.contains("aliasWithoutId2"));
 | 
			
		||||
		Assert.assertTrue(tb3Aliases.contains("aliasWithoutId3"));
 | 
			
		||||
		Assert.assertTrue(beanNames.contains("aliasWithoutId1"));
 | 
			
		||||
		Assert.assertFalse(beanNames.contains("aliasWithoutId2"));
 | 
			
		||||
		Assert.assertFalse(beanNames.contains("aliasWithoutId3"));
 | 
			
		||||
		assertEquals(2, tb3Aliases.size());
 | 
			
		||||
		assertTrue(tb3Aliases.contains("aliasWithoutId2"));
 | 
			
		||||
		assertTrue(tb3Aliases.contains("aliasWithoutId3"));
 | 
			
		||||
		assertTrue(beanNames.contains("aliasWithoutId1"));
 | 
			
		||||
		assertFalse(beanNames.contains("aliasWithoutId2"));
 | 
			
		||||
		assertFalse(beanNames.contains("aliasWithoutId3"));
 | 
			
		||||
 | 
			
		||||
		TestBean tb4 = (TestBean) getBeanFactory().getBean(TestBean.class.getName() + "#0");
 | 
			
		||||
		Assert.assertEquals(null, tb4.getName());
 | 
			
		||||
		assertEquals(null, tb4.getName());
 | 
			
		||||
 | 
			
		||||
		Map drs = getListableBeanFactory().getBeansOfType(DummyReferencer.class, false, false);
 | 
			
		||||
		Assert.assertEquals(5, drs.size());
 | 
			
		||||
		Assert.assertTrue(drs.containsKey(DummyReferencer.class.getName() + "#0"));
 | 
			
		||||
		Assert.assertTrue(drs.containsKey(DummyReferencer.class.getName() + "#1"));
 | 
			
		||||
		Assert.assertTrue(drs.containsKey(DummyReferencer.class.getName() + "#2"));
 | 
			
		||||
		assertEquals(5, drs.size());
 | 
			
		||||
		assertTrue(drs.containsKey(DummyReferencer.class.getName() + "#0"));
 | 
			
		||||
		assertTrue(drs.containsKey(DummyReferencer.class.getName() + "#1"));
 | 
			
		||||
		assertTrue(drs.containsKey(DummyReferencer.class.getName() + "#2"));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void testFactoryNesting() {
 | 
			
		||||
		ITestBean father = (ITestBean) getBeanFactory().getBean("father");
 | 
			
		||||
		Assert.assertTrue("Bean from root context", father != null);
 | 
			
		||||
		assertTrue("Bean from root context", father != null);
 | 
			
		||||
 | 
			
		||||
		TestBean rod = (TestBean) getBeanFactory().getBean("rod");
 | 
			
		||||
		Assert.assertTrue("Bean from child context", "Rod".equals(rod.getName()));
 | 
			
		||||
		Assert.assertTrue("Bean has external reference", rod.getSpouse() == father);
 | 
			
		||||
		assertTrue("Bean from child context", "Rod".equals(rod.getName()));
 | 
			
		||||
		assertTrue("Bean has external reference", rod.getSpouse() == father);
 | 
			
		||||
 | 
			
		||||
		rod = (TestBean) parent.getBean("rod");
 | 
			
		||||
		Assert.assertTrue("Bean from root context", "Roderick".equals(rod.getName()));
 | 
			
		||||
		assertTrue("Bean from root context", "Roderick".equals(rod.getName()));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void testFactoryReferences() {
 | 
			
		||||
		DummyFactory factory = (DummyFactory) getBeanFactory().getBean("&singletonFactory");
 | 
			
		||||
 | 
			
		||||
		DummyReferencer ref = (DummyReferencer) getBeanFactory().getBean("factoryReferencer");
 | 
			
		||||
		Assert.assertTrue(ref.getTestBean1() == ref.getTestBean2());
 | 
			
		||||
		Assert.assertTrue(ref.getDummyFactory() == factory);
 | 
			
		||||
		assertTrue(ref.getTestBean1() == ref.getTestBean2());
 | 
			
		||||
		assertTrue(ref.getDummyFactory() == factory);
 | 
			
		||||
 | 
			
		||||
		DummyReferencer ref2 = (DummyReferencer) getBeanFactory().getBean("factoryReferencerWithConstructor");
 | 
			
		||||
		Assert.assertTrue(ref2.getTestBean1() == ref2.getTestBean2());
 | 
			
		||||
		Assert.assertTrue(ref2.getDummyFactory() == factory);
 | 
			
		||||
		assertTrue(ref2.getTestBean1() == ref2.getTestBean2());
 | 
			
		||||
		assertTrue(ref2.getDummyFactory() == factory);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void testPrototypeReferences() {
 | 
			
		||||
		// check that not broken by circular reference resolution mechanism
 | 
			
		||||
		DummyReferencer ref1 = (DummyReferencer) getBeanFactory().getBean("prototypeReferencer");
 | 
			
		||||
		Assert.assertTrue("Not referencing same bean twice", ref1.getTestBean1() != ref1.getTestBean2());
 | 
			
		||||
		assertTrue("Not referencing same bean twice", ref1.getTestBean1() != ref1.getTestBean2());
 | 
			
		||||
		DummyReferencer ref2 = (DummyReferencer) getBeanFactory().getBean("prototypeReferencer");
 | 
			
		||||
		Assert.assertTrue("Not the same referencer", ref1 != ref2);
 | 
			
		||||
		Assert.assertTrue("Not referencing same bean twice", ref2.getTestBean1() != ref2.getTestBean2());
 | 
			
		||||
		Assert.assertTrue("Not referencing same bean twice", ref1.getTestBean1() != ref2.getTestBean1());
 | 
			
		||||
		Assert.assertTrue("Not referencing same bean twice", ref1.getTestBean2() != ref2.getTestBean2());
 | 
			
		||||
		Assert.assertTrue("Not referencing same bean twice", ref1.getTestBean1() != ref2.getTestBean2());
 | 
			
		||||
		assertTrue("Not the same referencer", ref1 != ref2);
 | 
			
		||||
		assertTrue("Not referencing same bean twice", ref2.getTestBean1() != ref2.getTestBean2());
 | 
			
		||||
		assertTrue("Not referencing same bean twice", ref1.getTestBean1() != ref2.getTestBean1());
 | 
			
		||||
		assertTrue("Not referencing same bean twice", ref1.getTestBean2() != ref2.getTestBean2());
 | 
			
		||||
		assertTrue("Not referencing same bean twice", ref1.getTestBean1() != ref2.getTestBean2());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void testBeanPostProcessor() throws Exception {
 | 
			
		||||
| 
						 | 
				
			
			@ -212,22 +214,22 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest
 | 
			
		|||
		TestBean kathy = (TestBean) getBeanFactory().getBean("kathy");
 | 
			
		||||
		DummyFactory factory = (DummyFactory) getBeanFactory().getBean("&singletonFactory");
 | 
			
		||||
		TestBean factoryCreated = (TestBean) getBeanFactory().getBean("singletonFactory");
 | 
			
		||||
		Assert.assertTrue(kerry.isPostProcessed());
 | 
			
		||||
		Assert.assertTrue(kathy.isPostProcessed());
 | 
			
		||||
		Assert.assertTrue(factory.isPostProcessed());
 | 
			
		||||
		Assert.assertTrue(factoryCreated.isPostProcessed());
 | 
			
		||||
		assertTrue(kerry.isPostProcessed());
 | 
			
		||||
		assertTrue(kathy.isPostProcessed());
 | 
			
		||||
		assertTrue(factory.isPostProcessed());
 | 
			
		||||
		assertTrue(factoryCreated.isPostProcessed());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void testEmptyValues() {
 | 
			
		||||
		TestBean rod = (TestBean) getBeanFactory().getBean("rod");
 | 
			
		||||
		TestBean kerry = (TestBean) getBeanFactory().getBean("kerry");
 | 
			
		||||
		Assert.assertTrue("Touchy is empty", "".equals(rod.getTouchy()));
 | 
			
		||||
		Assert.assertTrue("Touchy is empty", "".equals(kerry.getTouchy()));
 | 
			
		||||
		assertTrue("Touchy is empty", "".equals(rod.getTouchy()));
 | 
			
		||||
		assertTrue("Touchy is empty", "".equals(kerry.getTouchy()));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void testCommentsAndCdataInValue() {
 | 
			
		||||
		TestBean bean = (TestBean) getBeanFactory().getBean("commentsInValue");
 | 
			
		||||
		Assert.assertEquals("Failed to handle comments and CDATA properly", "this is a <!--comment-->", bean.getName());
 | 
			
		||||
		assertEquals("Failed to handle comments and CDATA properly", "this is a <!--comment-->", bean.getName());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,8 +20,10 @@ import java.io.IOException;
 | 
			
		|||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
import java.util.GregorianCalendar;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Properties;
 | 
			
		||||
 | 
			
		||||
import javax.activation.FileTypeMap;
 | 
			
		||||
import javax.mail.Address;
 | 
			
		||||
import javax.mail.Message;
 | 
			
		||||
| 
						 | 
				
			
			@ -59,7 +61,7 @@ public class JavaMailSenderTests extends TestCase {
 | 
			
		|||
		simpleMessage.setTo("you@mail.org");
 | 
			
		||||
		simpleMessage.setCc(new String[] {"he@mail.org", "she@mail.org"});
 | 
			
		||||
		simpleMessage.setBcc(new String[] {"us@mail.org", "them@mail.org"});
 | 
			
		||||
		Date sentDate = new Date(2004, 1, 1);
 | 
			
		||||
		Date sentDate = new GregorianCalendar(2004, 1, 1).getTime();
 | 
			
		||||
		simpleMessage.setSentDate(sentDate);
 | 
			
		||||
		simpleMessage.setSubject("my subject");
 | 
			
		||||
		simpleMessage.setText("my text");
 | 
			
		||||
| 
						 | 
				
			
			@ -334,7 +336,7 @@ public class JavaMailSenderTests extends TestCase {
 | 
			
		|||
		MimeMessage mimeMessage = sender.createMimeMessage();
 | 
			
		||||
		mimeMessage.setSubject("custom");
 | 
			
		||||
		mimeMessage.setRecipient(Message.RecipientType.TO, new InternetAddress("you@mail.org"));
 | 
			
		||||
		mimeMessage.setSentDate(new Date(2005, 3, 1));
 | 
			
		||||
		mimeMessage.setSentDate(new GregorianCalendar(2005, 3, 1).getTime());
 | 
			
		||||
		sender.send(mimeMessage);
 | 
			
		||||
 | 
			
		||||
		assertEquals("host", sender.transport.getConnectedHost());
 | 
			
		||||
| 
						 | 
				
			
			@ -559,7 +561,7 @@ public class JavaMailSenderTests extends TestCase {
 | 
			
		|||
				throw new MessagingException("No sentDate specified");
 | 
			
		||||
			}
 | 
			
		||||
			if (message.getSubject() != null && message.getSubject().contains("custom")) {
 | 
			
		||||
				assertEquals(new Date(2005, 3, 1), message.getSentDate());
 | 
			
		||||
				assertEquals(new GregorianCalendar(2005, 3, 1).getTime(), message.getSentDate());
 | 
			
		||||
			}
 | 
			
		||||
			this.sentMessages.add(message);
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -51,17 +51,18 @@ import org.quartz.Trigger;
 | 
			
		|||
import org.quartz.TriggerListener;
 | 
			
		||||
import org.quartz.impl.SchedulerRepository;
 | 
			
		||||
import org.quartz.spi.JobFactory;
 | 
			
		||||
 | 
			
		||||
import org.springframework.beans.TestBean;
 | 
			
		||||
import org.springframework.beans.factory.config.BeanDefinition;
 | 
			
		||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
 | 
			
		||||
import org.springframework.beans.factory.support.RootBeanDefinition;
 | 
			
		||||
import org.springframework.beans.factory.support.StaticListableBeanFactory;
 | 
			
		||||
import org.springframework.tests.Assume;
 | 
			
		||||
import org.springframework.tests.TestGroup;
 | 
			
		||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
 | 
			
		||||
import org.springframework.context.support.StaticApplicationContext;
 | 
			
		||||
import org.springframework.core.io.FileSystemResourceLoader;
 | 
			
		||||
import org.springframework.core.task.TaskExecutor;
 | 
			
		||||
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
 | 
			
		||||
import org.springframework.jdbc.core.JdbcTemplate;
 | 
			
		||||
import org.springframework.scheduling.TestMethodInvokingTask;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			@ -964,12 +965,14 @@ public class QuartzSupportTests {
 | 
			
		|||
	// SPR-6038: detect HSQL and stop illegal locks being taken
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testSchedulerWithHsqlDataSource() throws Exception {
 | 
			
		||||
		Assume.group(TestGroup.PERFORMANCE);
 | 
			
		||||
 | 
			
		||||
		DummyJob.param = 0;
 | 
			
		||||
		DummyJob.count = 0;
 | 
			
		||||
 | 
			
		||||
		ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
 | 
			
		||||
				"/org/springframework/scheduling/quartz/databasePersistence.xml");
 | 
			
		||||
		SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(ctx.getBean(DataSource.class));
 | 
			
		||||
		JdbcTemplate jdbcTemplate = new JdbcTemplate(ctx.getBean(DataSource.class));
 | 
			
		||||
		assertTrue("No triggers were persisted", jdbcTemplate.queryForList("SELECT * FROM qrtz_triggers").size()>0);
 | 
			
		||||
		Thread.sleep(3000);
 | 
			
		||||
		try {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -198,7 +198,7 @@ public class JasperReportsUtilsTests extends TestCase {
 | 
			
		|||
		HSSFRow row = sheet.getRow(3);
 | 
			
		||||
		HSSFCell cell = row.getCell((short) 1);
 | 
			
		||||
		assertNotNull("Cell should not be null", cell);
 | 
			
		||||
		assertEquals("Cell content should be Dear Lord!", "Dear Lord!", cell.getStringCellValue());
 | 
			
		||||
		assertEquals("Cell content should be Dear Lord!", "Dear Lord!", cell.getRichStringCellValue().getString());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private JasperReport getReport() throws Exception {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -56,6 +56,7 @@ import org.springframework.instrument.classloading.websphere.WebSphereLoadTimeWe
 | 
			
		|||
 * @since 2.5
 | 
			
		||||
 * @see org.springframework.context.ConfigurableApplicationContext#LOAD_TIME_WEAVER_BEAN_NAME
 | 
			
		||||
 */
 | 
			
		||||
@SuppressWarnings("deprecation")
 | 
			
		||||
public class DefaultContextLoadTimeWeaver implements LoadTimeWeaver, BeanClassLoaderAware, DisposableBean {
 | 
			
		||||
 | 
			
		||||
	protected final Log logger = LogFactory.getLog(getClass());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -99,6 +99,7 @@ class ScriptBeanDefinitionParser extends AbstractBeanDefinitionParser {
 | 
			
		|||
	 * Registers a {@link ScriptFactoryPostProcessor} if needed.
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	@SuppressWarnings("deprecation")
 | 
			
		||||
	protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
 | 
			
		||||
		// Resolve the script source.
 | 
			
		||||
		String value = resolveScriptSource(element, parserContext.getReaderContext());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -75,6 +75,7 @@ public abstract class JRubyScriptUtils {
 | 
			
		|||
	 * @return the scripted Java object
 | 
			
		||||
	 * @throws JumpException in case of JRuby parsing failure
 | 
			
		||||
	 */
 | 
			
		||||
	@SuppressWarnings("deprecation")
 | 
			
		||||
	public static Object createJRubyObject(String scriptSource, Class[] interfaces, ClassLoader classLoader) {
 | 
			
		||||
		Ruby ruby = initializeRuntime();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -51,8 +51,8 @@ import org.springframework.beans.factory.config.MethodInvokingFactoryBean;
 | 
			
		|||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.support.RootBeanDefinition;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 | 
			
		||||
import org.springframework.build.junit.Assume;
 | 
			
		||||
import org.springframework.build.junit.TestGroup;
 | 
			
		||||
import org.springframework.tests.Assume;
 | 
			
		||||
import org.springframework.tests.TestGroup;
 | 
			
		||||
import org.springframework.context.ApplicationContext;
 | 
			
		||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
 | 
			
		||||
import org.springframework.context.support.GenericApplicationContext;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,8 +16,16 @@
 | 
			
		|||
 | 
			
		||||
package org.springframework.aop.framework;
 | 
			
		||||
 | 
			
		||||
import static org.hamcrest.CoreMatchers.*;
 | 
			
		||||
import static org.junit.Assert.*;
 | 
			
		||||
import static org.hamcrest.CoreMatchers.instanceOf;
 | 
			
		||||
import static org.hamcrest.CoreMatchers.not;
 | 
			
		||||
import static org.junit.Assert.assertArrayEquals;
 | 
			
		||||
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.IOException;
 | 
			
		||||
| 
						 | 
				
			
			@ -45,10 +53,10 @@ import org.springframework.beans.TestBean;
 | 
			
		|||
import org.springframework.beans.factory.BeanCreationException;
 | 
			
		||||
import org.springframework.beans.factory.BeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.FactoryBean;
 | 
			
		||||
import org.springframework.beans.factory.ListableBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.support.RootBeanDefinition;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 | 
			
		||||
import org.springframework.context.ApplicationListener;
 | 
			
		||||
import org.springframework.context.TestListener;
 | 
			
		||||
import org.springframework.core.io.ClassPathResource;
 | 
			
		||||
| 
						 | 
				
			
			@ -56,14 +64,13 @@ import org.springframework.util.SerializationTestUtils;
 | 
			
		|||
 | 
			
		||||
import test.advice.CountingBeforeAdvice;
 | 
			
		||||
import test.advice.MyThrowsHandler;
 | 
			
		||||
import test.beans.SideEffectBean;
 | 
			
		||||
import test.interceptor.NopInterceptor;
 | 
			
		||||
import test.interceptor.TimestampIntroductionInterceptor;
 | 
			
		||||
import test.mixin.Lockable;
 | 
			
		||||
import test.mixin.LockedException;
 | 
			
		||||
import test.util.TimeStamped;
 | 
			
		||||
 | 
			
		||||
import test.beans.SideEffectBean;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @since 13.03.2003
 | 
			
		||||
 * @author Rod Johnson
 | 
			
		||||
| 
						 | 
				
			
			@ -93,7 +100,9 @@ public final class ProxyFactoryBeanTests {
 | 
			
		|||
	public void setUp() throws Exception {
 | 
			
		||||
		DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
 | 
			
		||||
		parent.registerBeanDefinition("target2", new RootBeanDefinition(TestListener.class));
 | 
			
		||||
		this.factory = new XmlBeanFactory(new ClassPathResource(CONTEXT, getClass()), parent);
 | 
			
		||||
		this.factory = new DefaultListableBeanFactory(parent);
 | 
			
		||||
		new XmlBeanDefinitionReader((BeanDefinitionRegistry) this.factory).loadBeanDefinitions(
 | 
			
		||||
				new ClassPathResource(CONTEXT, getClass()));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Test
 | 
			
		||||
| 
						 | 
				
			
			@ -133,7 +142,8 @@ public final class ProxyFactoryBeanTests {
 | 
			
		|||
 | 
			
		||||
	private void testDoubleTargetSourceIsRejected(String name) {
 | 
			
		||||
		try {
 | 
			
		||||
			BeanFactory bf = new XmlBeanFactory(new ClassPathResource(DBL_TARGETSOURCE_CONTEXT, CLASS));
 | 
			
		||||
			DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
			new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(DBL_TARGETSOURCE_CONTEXT, CLASS));
 | 
			
		||||
			bf.getBean(name);
 | 
			
		||||
			fail("Should not allow TargetSource to be specified in interceptorNames as well as targetSource property");
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -147,7 +157,8 @@ public final class ProxyFactoryBeanTests {
 | 
			
		|||
	@Test
 | 
			
		||||
	public void testTargetSourceNotAtEndOfInterceptorNamesIsRejected() {
 | 
			
		||||
		try {
 | 
			
		||||
			BeanFactory bf = new XmlBeanFactory(new ClassPathResource(NOTLAST_TARGETSOURCE_CONTEXT, CLASS));
 | 
			
		||||
			DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
			new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(NOTLAST_TARGETSOURCE_CONTEXT, CLASS));
 | 
			
		||||
			bf.getBean("targetSourceNotLast");
 | 
			
		||||
			fail("TargetSource or non-advised object must be last in interceptorNames");
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -160,7 +171,8 @@ public final class ProxyFactoryBeanTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testGetObjectTypeWithDirectTarget() {
 | 
			
		||||
		BeanFactory bf = new XmlBeanFactory(new ClassPathResource(TARGETSOURCE_CONTEXT, CLASS));
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(TARGETSOURCE_CONTEXT, CLASS));
 | 
			
		||||
 | 
			
		||||
		// We have a counting before advice here
 | 
			
		||||
		CountingBeforeAdvice cba = (CountingBeforeAdvice) bf.getBean("countingBeforeAdvice");
 | 
			
		||||
| 
						 | 
				
			
			@ -176,7 +188,8 @@ public final class ProxyFactoryBeanTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testGetObjectTypeWithTargetViaTargetSource() {
 | 
			
		||||
		BeanFactory bf = new XmlBeanFactory(new ClassPathResource(TARGETSOURCE_CONTEXT, CLASS));
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(TARGETSOURCE_CONTEXT, CLASS));
 | 
			
		||||
		ITestBean tb = (ITestBean) bf.getBean("viaTargetSource");
 | 
			
		||||
		assertTrue(tb.getName().equals("Adam"));
 | 
			
		||||
		ProxyFactoryBean pfb = (ProxyFactoryBean) bf.getBean("&viaTargetSource");
 | 
			
		||||
| 
						 | 
				
			
			@ -185,7 +198,8 @@ public final class ProxyFactoryBeanTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testGetObjectTypeWithNoTargetOrTargetSource() {
 | 
			
		||||
		BeanFactory bf = new XmlBeanFactory(new ClassPathResource(TARGETSOURCE_CONTEXT, CLASS));
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(TARGETSOURCE_CONTEXT, CLASS));
 | 
			
		||||
 | 
			
		||||
		ITestBean tb = (ITestBean) bf.getBean("noTarget");
 | 
			
		||||
		try {
 | 
			
		||||
| 
						 | 
				
			
			@ -246,7 +260,8 @@ public final class ProxyFactoryBeanTests {
 | 
			
		|||
		// Initial count value set in bean factory XML
 | 
			
		||||
		int INITIAL_COUNT = 10;
 | 
			
		||||
 | 
			
		||||
		BeanFactory bf = new XmlBeanFactory(new ClassPathResource(PROTOTYPE_CONTEXT, CLASS));
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(PROTOTYPE_CONTEXT, CLASS));
 | 
			
		||||
 | 
			
		||||
		// Check it works without AOP
 | 
			
		||||
		SideEffectBean raw = (SideEffectBean) bf.getBean("prototypeTarget");
 | 
			
		||||
| 
						 | 
				
			
			@ -338,7 +353,8 @@ public final class ProxyFactoryBeanTests {
 | 
			
		|||
	 */
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testTargetAsInnerBean() {
 | 
			
		||||
		ListableBeanFactory bf = new XmlBeanFactory(new ClassPathResource(INNER_BEAN_TARGET_CONTEXT, CLASS));
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(INNER_BEAN_TARGET_CONTEXT, CLASS));
 | 
			
		||||
		ITestBean itb = (ITestBean) bf.getBean("testBean");
 | 
			
		||||
		assertEquals("innerBeanTarget", itb.getName());
 | 
			
		||||
		assertEquals("Only have proxy and interceptor: no target", 3, bf.getBeanDefinitionCount());
 | 
			
		||||
| 
						 | 
				
			
			@ -441,7 +457,8 @@ public final class ProxyFactoryBeanTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testCanAddThrowsAdviceWithoutAdvisor() throws Throwable {
 | 
			
		||||
		BeanFactory f = new XmlBeanFactory(new ClassPathResource(THROWS_ADVICE_CONTEXT, CLASS));
 | 
			
		||||
		DefaultListableBeanFactory f = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(f).loadBeanDefinitions(new ClassPathResource(THROWS_ADVICE_CONTEXT, CLASS));
 | 
			
		||||
		MyThrowsHandler th = (MyThrowsHandler) f.getBean("throwsAdvice");
 | 
			
		||||
		CountingBeforeAdvice cba = (CountingBeforeAdvice) f.getBean("countingBeforeAdvice");
 | 
			
		||||
		assertEquals(0, cba.getCalls());
 | 
			
		||||
| 
						 | 
				
			
			@ -498,9 +515,10 @@ public final class ProxyFactoryBeanTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testEmptyInterceptorNames() {
 | 
			
		||||
		XmlBeanFactory factory = new XmlBeanFactory(new ClassPathResource(INVALID_CONTEXT, CLASS));
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(INVALID_CONTEXT, CLASS));
 | 
			
		||||
		try {
 | 
			
		||||
			factory.getBean("emptyInterceptorNames");
 | 
			
		||||
			bf.getBean("emptyInterceptorNames");
 | 
			
		||||
			fail("Interceptor names cannot be empty");
 | 
			
		||||
		}
 | 
			
		||||
		catch (BeanCreationException ex) {
 | 
			
		||||
| 
						 | 
				
			
			@ -513,9 +531,10 @@ public final class ProxyFactoryBeanTests {
 | 
			
		|||
	 */
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testGlobalsWithoutTarget() {
 | 
			
		||||
		XmlBeanFactory factory = new XmlBeanFactory(new ClassPathResource(INVALID_CONTEXT, CLASS));
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(INVALID_CONTEXT, CLASS));
 | 
			
		||||
		try {
 | 
			
		||||
			factory.getBean("globalsWithoutTarget");
 | 
			
		||||
			bf.getBean("globalsWithoutTarget");
 | 
			
		||||
			fail("Should require target name");
 | 
			
		||||
		}
 | 
			
		||||
		catch (BeanCreationException ex) {
 | 
			
		||||
| 
						 | 
				
			
			@ -554,7 +573,8 @@ public final class ProxyFactoryBeanTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testSerializableSingletonProxy() throws Exception {
 | 
			
		||||
		BeanFactory bf = new XmlBeanFactory(new ClassPathResource(SERIALIZATION_CONTEXT, CLASS));
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(SERIALIZATION_CONTEXT, CLASS));
 | 
			
		||||
		Person p = (Person) bf.getBean("serializableSingleton");
 | 
			
		||||
		assertSame("Should be a Singleton", p, bf.getBean("serializableSingleton"));
 | 
			
		||||
		Person p2 = (Person) SerializationTestUtils.serializeAndDeserialize(p);
 | 
			
		||||
| 
						 | 
				
			
			@ -576,7 +596,8 @@ public final class ProxyFactoryBeanTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testSerializablePrototypeProxy() throws Exception {
 | 
			
		||||
		BeanFactory bf = new XmlBeanFactory(new ClassPathResource(SERIALIZATION_CONTEXT, CLASS));
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(SERIALIZATION_CONTEXT, CLASS));
 | 
			
		||||
		Person p = (Person) bf.getBean("serializablePrototype");
 | 
			
		||||
		assertNotSame("Should not be a Singleton", p, bf.getBean("serializablePrototype"));
 | 
			
		||||
		Person p2 = (Person) SerializationTestUtils.serializeAndDeserialize(p);
 | 
			
		||||
| 
						 | 
				
			
			@ -587,7 +608,8 @@ public final class ProxyFactoryBeanTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testSerializableSingletonProxyFactoryBean() throws Exception {
 | 
			
		||||
		BeanFactory bf = new XmlBeanFactory(new ClassPathResource(SERIALIZATION_CONTEXT, CLASS));
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(SERIALIZATION_CONTEXT, CLASS));
 | 
			
		||||
		Person p = (Person) bf.getBean("serializableSingleton");
 | 
			
		||||
		ProxyFactoryBean pfb = (ProxyFactoryBean) bf.getBean("&serializableSingleton");
 | 
			
		||||
		ProxyFactoryBean pfb2 = (ProxyFactoryBean) SerializationTestUtils.serializeAndDeserialize(pfb);
 | 
			
		||||
| 
						 | 
				
			
			@ -599,14 +621,16 @@ public final class ProxyFactoryBeanTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testProxyNotSerializableBecauseOfAdvice() throws Exception {
 | 
			
		||||
		BeanFactory bf = new XmlBeanFactory(new ClassPathResource(SERIALIZATION_CONTEXT, CLASS));
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(SERIALIZATION_CONTEXT, CLASS));
 | 
			
		||||
		Person p = (Person) bf.getBean("interceptorNotSerializableSingleton");
 | 
			
		||||
		assertFalse("Not serializable because an interceptor isn't serializable", SerializationTestUtils.isSerializable(p));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testPrototypeAdvisor() {
 | 
			
		||||
		BeanFactory bf = new XmlBeanFactory(new ClassPathResource(CONTEXT, CLASS));
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(CONTEXT, CLASS));
 | 
			
		||||
 | 
			
		||||
		ITestBean bean1 = (ITestBean) bf.getBean("prototypeTestBeanProxy");
 | 
			
		||||
		ITestBean bean2 = (ITestBean) bf.getBean("prototypeTestBeanProxy");
 | 
			
		||||
| 
						 | 
				
			
			@ -637,7 +661,8 @@ public final class ProxyFactoryBeanTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testPrototypeInterceptorSingletonTarget() {
 | 
			
		||||
		BeanFactory bf = new XmlBeanFactory(new ClassPathResource(CONTEXT, CLASS));
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(CONTEXT, CLASS));
 | 
			
		||||
 | 
			
		||||
		ITestBean bean1 = (ITestBean) bf.getBean("prototypeTestBeanProxySingletonTarget");
 | 
			
		||||
		ITestBean bean2 = (ITestBean) bf.getBean("prototypeTestBeanProxySingletonTarget");
 | 
			
		||||
| 
						 | 
				
			
			@ -671,13 +696,15 @@ public final class ProxyFactoryBeanTests {
 | 
			
		|||
	 */
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testInnerBeanTargetUsingAutowiring() {
 | 
			
		||||
		BeanFactory bf = new XmlBeanFactory(new ClassPathResource(AUTOWIRING_CONTEXT, CLASS));
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(AUTOWIRING_CONTEXT, CLASS));
 | 
			
		||||
		bf.getBean("testBean");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testFrozenFactoryBean() {
 | 
			
		||||
		BeanFactory bf = new XmlBeanFactory(new ClassPathResource(FROZEN_CONTEXT, CLASS));
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(FROZEN_CONTEXT, CLASS));
 | 
			
		||||
 | 
			
		||||
		Advised advised = (Advised)bf.getBean("frozen");
 | 
			
		||||
		assertTrue("The proxy should be frozen", advised.isFrozen());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -55,7 +55,8 @@ public final class AutoProxyCreatorTests {
 | 
			
		|||
		proxyCreator.getPropertyValues().add("beanNames", "singletonToBeProxied,innerBean,singletonFactoryToBeProxied");
 | 
			
		||||
		sac.getDefaultListableBeanFactory().registerBeanDefinition("beanNameAutoProxyCreator", proxyCreator);
 | 
			
		||||
 | 
			
		||||
		RootBeanDefinition bd = new RootBeanDefinition(TestBean.class, RootBeanDefinition.AUTOWIRE_BY_TYPE);
 | 
			
		||||
		RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		bd.setAutowireMode(RootBeanDefinition.AUTOWIRE_BY_TYPE);
 | 
			
		||||
		RootBeanDefinition innerBean = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		bd.getPropertyValues().add("spouse", new BeanDefinitionHolder(innerBean, "innerBean"));
 | 
			
		||||
		sac.getDefaultListableBeanFactory().registerBeanDefinition("singletonToBeProxied", bd);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,19 +16,21 @@
 | 
			
		|||
 | 
			
		||||
package org.springframework.aop.scope;
 | 
			
		||||
 | 
			
		||||
import static org.junit.Assert.assertEquals;
 | 
			
		||||
import static org.junit.Assert.assertNotNull;
 | 
			
		||||
import static org.junit.Assert.assertTrue;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
import static org.junit.Assert.*;
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
 | 
			
		||||
import org.springframework.aop.support.AopUtils;
 | 
			
		||||
import org.springframework.beans.ITestBean;
 | 
			
		||||
import org.springframework.beans.TestBean;
 | 
			
		||||
import org.springframework.beans.factory.config.SimpleMapScope;
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
 | 
			
		||||
import org.springframework.context.support.GenericApplicationContext;
 | 
			
		||||
import org.springframework.core.io.ClassPathResource;
 | 
			
		||||
import org.springframework.util.SerializationTestUtils;
 | 
			
		||||
| 
						 | 
				
			
			@ -51,14 +53,16 @@ public class ScopedProxyTests {
 | 
			
		|||
	/* SPR-2108 */
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testProxyAssignable() throws Exception {
 | 
			
		||||
		XmlBeanFactory bf = new XmlBeanFactory(MAP_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(MAP_CONTEXT);
 | 
			
		||||
		Object baseMap = bf.getBean("singletonMap");
 | 
			
		||||
		assertTrue(baseMap instanceof Map);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testSimpleProxy() throws Exception {
 | 
			
		||||
		XmlBeanFactory bf = new XmlBeanFactory(MAP_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(MAP_CONTEXT);
 | 
			
		||||
		Object simpleMap = bf.getBean("simpleMap");
 | 
			
		||||
		assertTrue(simpleMap instanceof Map);
 | 
			
		||||
		assertTrue(simpleMap instanceof HashMap);
 | 
			
		||||
| 
						 | 
				
			
			@ -82,7 +86,8 @@ public class ScopedProxyTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testJdkScopedProxy() throws Exception {
 | 
			
		||||
		XmlBeanFactory bf = new XmlBeanFactory(TESTBEAN_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(TESTBEAN_CONTEXT);
 | 
			
		||||
		bf.setSerializationId("X");
 | 
			
		||||
		SimpleMapScope scope = new SimpleMapScope();
 | 
			
		||||
		bf.registerScope("request", scope);
 | 
			
		||||
| 
						 | 
				
			
			@ -111,7 +116,8 @@ public class ScopedProxyTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void testCglibScopedProxy() throws Exception {
 | 
			
		||||
		XmlBeanFactory bf = new XmlBeanFactory(LIST_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(LIST_CONTEXT);
 | 
			
		||||
		bf.setSerializationId("Y");
 | 
			
		||||
		SimpleMapScope scope = new SimpleMapScope();
 | 
			
		||||
		bf.registerScope("request", scope);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,7 +16,10 @@
 | 
			
		|||
 | 
			
		||||
package org.springframework.aop.target;
 | 
			
		||||
 | 
			
		||||
import static org.junit.Assert.*;
 | 
			
		||||
import static org.junit.Assert.assertEquals;
 | 
			
		||||
import static org.junit.Assert.assertNotNull;
 | 
			
		||||
import static org.junit.Assert.assertTrue;
 | 
			
		||||
import static org.junit.Assert.fail;
 | 
			
		||||
 | 
			
		||||
import java.util.NoSuchElementException;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -27,7 +30,8 @@ import org.junit.Test;
 | 
			
		|||
import org.springframework.aop.framework.Advised;
 | 
			
		||||
import org.springframework.beans.Person;
 | 
			
		||||
import org.springframework.beans.SerializablePerson;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 | 
			
		||||
import org.springframework.context.support.StaticApplicationContext;
 | 
			
		||||
import org.springframework.core.io.ClassPathResource;
 | 
			
		||||
import org.springframework.util.SerializationTestUtils;
 | 
			
		||||
| 
						 | 
				
			
			@ -50,11 +54,13 @@ public class CommonsPoolTargetSourceTests {
 | 
			
		|||
	 */
 | 
			
		||||
	private static final int INITIAL_COUNT = 10;
 | 
			
		||||
 | 
			
		||||
	private XmlBeanFactory beanFactory;
 | 
			
		||||
	private DefaultListableBeanFactory beanFactory;
 | 
			
		||||
 | 
			
		||||
	@Before
 | 
			
		||||
	public void setUp() throws Exception {
 | 
			
		||||
		this.beanFactory = new XmlBeanFactory(new ClassPathResource(getClass().getSimpleName() + "-context.xml", getClass()));
 | 
			
		||||
		this.beanFactory = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(
 | 
			
		||||
				new ClassPathResource(getClass().getSimpleName() + "-context.xml", getClass()));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,7 +20,6 @@ import java.beans.PropertyEditorSupport;
 | 
			
		|||
import java.util.StringTokenizer;
 | 
			
		||||
 | 
			
		||||
import junit.framework.TestCase;
 | 
			
		||||
import junit.framework.Assert;
 | 
			
		||||
 | 
			
		||||
import org.springframework.beans.BeansException;
 | 
			
		||||
import org.springframework.beans.PropertyBatchUpdateException;
 | 
			
		||||
| 
						 | 
				
			
			@ -79,7 +78,7 @@ public abstract class AbstractBeanFactoryTests extends TestCase {
 | 
			
		|||
	 */
 | 
			
		||||
	public void testLifecycleCallbacks() {
 | 
			
		||||
		LifecycleBean lb = (LifecycleBean) getBeanFactory().getBean("lifecycle");
 | 
			
		||||
		Assert.assertEquals("lifecycle", lb.getBeanName());
 | 
			
		||||
		assertEquals("lifecycle", lb.getBeanName());
 | 
			
		||||
		// The dummy business method will throw an exception if the
 | 
			
		||||
		// necessary callbacks weren't invoked in the right order.
 | 
			
		||||
		lb.businessMethod();
 | 
			
		||||
| 
						 | 
				
			
			@ -327,4 +326,4 @@ public abstract class AbstractBeanFactoryTests extends TestCase {
 | 
			
		|||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright 2002-2007 the original author or authors.
 | 
			
		||||
 * 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.
 | 
			
		||||
| 
						 | 
				
			
			@ -16,8 +16,6 @@
 | 
			
		|||
 | 
			
		||||
package org.springframework.beans.factory;
 | 
			
		||||
 | 
			
		||||
import junit.framework.Assert;
 | 
			
		||||
 | 
			
		||||
import org.springframework.beans.TestBean;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			@ -44,24 +42,24 @@ public abstract class AbstractListableBeanFactoryTests extends AbstractBeanFacto
 | 
			
		|||
 | 
			
		||||
	protected final void assertCount(int count) {
 | 
			
		||||
		String[] defnames = getListableBeanFactory().getBeanDefinitionNames();
 | 
			
		||||
		Assert.assertTrue("We should have " + count + " beans, not " + defnames.length, defnames.length == count);
 | 
			
		||||
		assertTrue("We should have " + count + " beans, not " + defnames.length, defnames.length == count);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void assertTestBeanCount(int count) {
 | 
			
		||||
		String[] defNames = getListableBeanFactory().getBeanNamesForType(TestBean.class, true, false);
 | 
			
		||||
		Assert.assertTrue("We should have " + count + " beans for class org.springframework.beans.TestBean, not " +
 | 
			
		||||
		assertTrue("We should have " + count + " beans for class org.springframework.beans.TestBean, not " +
 | 
			
		||||
				defNames.length, defNames.length == count);
 | 
			
		||||
 | 
			
		||||
		int countIncludingFactoryBeans = count + 2;
 | 
			
		||||
		String[] names = getListableBeanFactory().getBeanNamesForType(TestBean.class, true, true);
 | 
			
		||||
		Assert.assertTrue("We should have " + countIncludingFactoryBeans +
 | 
			
		||||
		assertTrue("We should have " + countIncludingFactoryBeans +
 | 
			
		||||
				" beans for class org.springframework.beans.TestBean, not " + names.length,
 | 
			
		||||
				names.length == countIncludingFactoryBeans);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void testGetDefinitionsForNoSuchClass() {
 | 
			
		||||
		String[] defnames = getListableBeanFactory().getBeanNamesForType(String.class);
 | 
			
		||||
		Assert.assertTrue("No string definitions", defnames.length == 0);
 | 
			
		||||
		assertTrue("No string definitions", defnames.length == 0);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
| 
						 | 
				
			
			@ -69,18 +67,18 @@ public abstract class AbstractListableBeanFactoryTests extends AbstractBeanFacto
 | 
			
		|||
	 * what type factories may return, and it may even change over time.)
 | 
			
		||||
	 */
 | 
			
		||||
	public void testGetCountForFactoryClass() {
 | 
			
		||||
		Assert.assertTrue("Should have 2 factories, not " +
 | 
			
		||||
		assertTrue("Should have 2 factories, not " +
 | 
			
		||||
				getListableBeanFactory().getBeanNamesForType(FactoryBean.class).length,
 | 
			
		||||
				getListableBeanFactory().getBeanNamesForType(FactoryBean.class).length == 2);
 | 
			
		||||
 | 
			
		||||
		Assert.assertTrue("Should have 2 factories, not " +
 | 
			
		||||
		assertTrue("Should have 2 factories, not " +
 | 
			
		||||
				getListableBeanFactory().getBeanNamesForType(FactoryBean.class).length,
 | 
			
		||||
				getListableBeanFactory().getBeanNamesForType(FactoryBean.class).length == 2);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void testContainsBeanDefinition() {
 | 
			
		||||
		Assert.assertTrue(getListableBeanFactory().containsBeanDefinition("rod"));
 | 
			
		||||
		Assert.assertTrue(getListableBeanFactory().containsBeanDefinition("roderick"));
 | 
			
		||||
		assertTrue(getListableBeanFactory().containsBeanDefinition("rod"));
 | 
			
		||||
		assertTrue(getListableBeanFactory().containsBeanDefinition("roderick"));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,12 +19,11 @@ package org.springframework.beans.factory.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.core.CollectionFactory;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Rob Harrop
 | 
			
		||||
 * @author Juergen Hoeller
 | 
			
		||||
| 
						 | 
				
			
			@ -33,9 +32,9 @@ public class CollectingReaderEventListener implements ReaderEventListener {
 | 
			
		|||
 | 
			
		||||
	private final List<DefaultsDefinition> defaults = new LinkedList<DefaultsDefinition>();
 | 
			
		||||
 | 
			
		||||
	private final Map<String, ComponentDefinition> componentDefinitions = CollectionFactory.createLinkedMapIfPossible(8);
 | 
			
		||||
	private final Map<String, ComponentDefinition> componentDefinitions = new LinkedHashMap<>(8);
 | 
			
		||||
 | 
			
		||||
	private final Map<String, List<AliasDefinition>> aliasMap = CollectionFactory.createLinkedMapIfPossible(8);
 | 
			
		||||
	private final Map<String, List<AliasDefinition>> aliasMap = new LinkedHashMap<>(8);
 | 
			
		||||
 | 
			
		||||
	private final List<ImportDefinition> imports = new LinkedList<ImportDefinition>();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -116,7 +116,6 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	private static final ClassPathResource NO_SUCH_FACTORY_METHOD_CONTEXT = classPathResource("-noSuchFactoryMethod.xml");
 | 
			
		||||
	private static final ClassPathResource RECURSIVE_IMPORT_CONTEXT = classPathResource("-recursiveImport.xml");
 | 
			
		||||
	private static final ClassPathResource RESOURCE_CONTEXT = classPathResource("-resource.xml");
 | 
			
		||||
	private static final ClassPathResource RESOURCE_IMPORT_CONTEXT = classPathResource("-resourceImport.xml");
 | 
			
		||||
	private static final ClassPathResource SATISFIED_ALL_DEP_CONTEXT = classPathResource("-satisfiedAllDepCheck.xml");
 | 
			
		||||
	private static final ClassPathResource SATISFIED_OBJECT_DEP_CONTEXT = classPathResource("-satisfiedObjectDepCheck.xml");
 | 
			
		||||
	private static final ClassPathResource SATISFIED_SIMPLE_DEP_CONTEXT = classPathResource("-satisfiedSimpleDepCheck.xml");
 | 
			
		||||
| 
						 | 
				
			
			@ -135,7 +134,8 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
 | 
			
		||||
	/* SPR-2368 */
 | 
			
		||||
	public @Test void testCollectionsReferredToAsRefLocals() throws Exception {
 | 
			
		||||
		XmlBeanFactory factory = new XmlBeanFactory(COLLECTIONS_XSD_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(factory).loadBeanDefinitions(COLLECTIONS_XSD_CONTEXT);
 | 
			
		||||
		factory.preInstantiateSingletons();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -296,8 +296,10 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testInheritanceFromParentFactoryPrototype() throws Exception {
 | 
			
		||||
		XmlBeanFactory parent = new XmlBeanFactory(PARENT_CONTEXT);
 | 
			
		||||
		XmlBeanFactory child = new XmlBeanFactory(CHILD_CONTEXT, parent);
 | 
			
		||||
		DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
 | 
			
		||||
		new XmlBeanDefinitionReader(child).loadBeanDefinitions(CHILD_CONTEXT);
 | 
			
		||||
		assertEquals(TestBean.class, child.getType("inheritsFromParentFactory"));
 | 
			
		||||
		TestBean inherits = (TestBean) child.getBean("inheritsFromParentFactory");
 | 
			
		||||
		// Name property value is overridden
 | 
			
		||||
| 
						 | 
				
			
			@ -309,8 +311,10 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testInheritanceWithDifferentClass() throws Exception {
 | 
			
		||||
		XmlBeanFactory parent = new XmlBeanFactory(PARENT_CONTEXT);
 | 
			
		||||
		XmlBeanFactory child = new XmlBeanFactory(CHILD_CONTEXT, parent);
 | 
			
		||||
		DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
 | 
			
		||||
		new XmlBeanDefinitionReader(child).loadBeanDefinitions(CHILD_CONTEXT);
 | 
			
		||||
		assertEquals(DerivedTestBean.class, child.getType("inheritsWithClass"));
 | 
			
		||||
		DerivedTestBean inherits = (DerivedTestBean) child.getBean("inheritsWithDifferentClass");
 | 
			
		||||
		// Name property value is overridden
 | 
			
		||||
| 
						 | 
				
			
			@ -321,8 +325,10 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testInheritanceWithClass() throws Exception {
 | 
			
		||||
		XmlBeanFactory parent = new XmlBeanFactory(PARENT_CONTEXT);
 | 
			
		||||
		XmlBeanFactory child = new XmlBeanFactory(CHILD_CONTEXT, parent);
 | 
			
		||||
		DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
 | 
			
		||||
		new XmlBeanDefinitionReader(child).loadBeanDefinitions(CHILD_CONTEXT);
 | 
			
		||||
		assertEquals(DerivedTestBean.class, child.getType("inheritsWithClass"));
 | 
			
		||||
		DerivedTestBean inherits = (DerivedTestBean) child.getBean("inheritsWithClass");
 | 
			
		||||
		// Name property value is overridden
 | 
			
		||||
| 
						 | 
				
			
			@ -333,8 +339,10 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testPrototypeInheritanceFromParentFactoryPrototype() throws Exception {
 | 
			
		||||
		XmlBeanFactory parent = new XmlBeanFactory(PARENT_CONTEXT);
 | 
			
		||||
		XmlBeanFactory child = new XmlBeanFactory(CHILD_CONTEXT, parent);
 | 
			
		||||
		DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
 | 
			
		||||
		new XmlBeanDefinitionReader(child).loadBeanDefinitions(CHILD_CONTEXT);
 | 
			
		||||
		assertEquals(TestBean.class, child.getType("prototypeInheritsFromParentFactoryPrototype"));
 | 
			
		||||
		TestBean inherits = (TestBean) child.getBean("prototypeInheritsFromParentFactoryPrototype");
 | 
			
		||||
		// Name property value is overridden
 | 
			
		||||
| 
						 | 
				
			
			@ -350,8 +358,10 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testPrototypeInheritanceFromParentFactorySingleton() throws Exception {
 | 
			
		||||
		XmlBeanFactory parent = new XmlBeanFactory(PARENT_CONTEXT);
 | 
			
		||||
		XmlBeanFactory child = new XmlBeanFactory(CHILD_CONTEXT, parent);
 | 
			
		||||
		DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
 | 
			
		||||
		new XmlBeanDefinitionReader(child).loadBeanDefinitions(CHILD_CONTEXT);
 | 
			
		||||
		TestBean inherits = (TestBean) child.getBean("protoypeInheritsFromParentFactorySingleton");
 | 
			
		||||
		// Name property value is overridden
 | 
			
		||||
		assertTrue(inherits.getName().equals("prototypeOverridesInheritedSingleton"));
 | 
			
		||||
| 
						 | 
				
			
			@ -380,7 +390,8 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testAbstractParentBeans() {
 | 
			
		||||
		XmlBeanFactory parent = new XmlBeanFactory(PARENT_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
 | 
			
		||||
		parent.preInstantiateSingletons();
 | 
			
		||||
		assertTrue(parent.isSingleton("inheritedTestBeanWithoutClass"));
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -404,7 +415,8 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testDependenciesMaterializeThis() throws Exception {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(DEP_MATERIALIZE_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(DEP_MATERIALIZE_CONTEXT);
 | 
			
		||||
 | 
			
		||||
		assertEquals(2, xbf.getBeansOfType(DummyBo.class, true, false).size());
 | 
			
		||||
		assertEquals(3, xbf.getBeansOfType(DummyBo.class, true, true).size());
 | 
			
		||||
| 
						 | 
				
			
			@ -421,8 +433,10 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testChildOverridesParentBean() throws Exception {
 | 
			
		||||
		XmlBeanFactory parent = new XmlBeanFactory(PARENT_CONTEXT);
 | 
			
		||||
		XmlBeanFactory child = new XmlBeanFactory(CHILD_CONTEXT, parent);
 | 
			
		||||
		DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
 | 
			
		||||
		new XmlBeanDefinitionReader(child).loadBeanDefinitions(CHILD_CONTEXT);
 | 
			
		||||
		TestBean inherits = (TestBean) child.getBean("inheritedTestBean");
 | 
			
		||||
		// Name property value is overridden
 | 
			
		||||
		assertTrue(inherits.getName().equals("overrideParentBean"));
 | 
			
		||||
| 
						 | 
				
			
			@ -437,8 +451,10 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	 * If a singleton does this the factory will fail to load.
 | 
			
		||||
	 */
 | 
			
		||||
	public @Test void testBogusParentageFromParentFactory() throws Exception {
 | 
			
		||||
		XmlBeanFactory parent = new XmlBeanFactory(PARENT_CONTEXT);
 | 
			
		||||
		XmlBeanFactory child = new XmlBeanFactory(CHILD_CONTEXT, parent);
 | 
			
		||||
		DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
 | 
			
		||||
		new XmlBeanDefinitionReader(child).loadBeanDefinitions(CHILD_CONTEXT);
 | 
			
		||||
		try {
 | 
			
		||||
			child.getBean("bogusParent", TestBean.class);
 | 
			
		||||
			fail();
 | 
			
		||||
| 
						 | 
				
			
			@ -456,8 +472,10 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	 * instances even if derived from a prototype
 | 
			
		||||
	 */
 | 
			
		||||
	public @Test void testSingletonInheritsFromParentFactoryPrototype() throws Exception {
 | 
			
		||||
		XmlBeanFactory parent = new XmlBeanFactory(PARENT_CONTEXT);
 | 
			
		||||
		XmlBeanFactory child = new XmlBeanFactory(CHILD_CONTEXT, parent);
 | 
			
		||||
		DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
 | 
			
		||||
		new XmlBeanDefinitionReader(child).loadBeanDefinitions(CHILD_CONTEXT);
 | 
			
		||||
		TestBean inherits = (TestBean) child.getBean("singletonInheritsFromParentFactoryPrototype");
 | 
			
		||||
		// Name property value is overriden
 | 
			
		||||
		assertTrue(inherits.getName().equals("prototype-override"));
 | 
			
		||||
| 
						 | 
				
			
			@ -468,16 +486,20 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testSingletonFromParent() {
 | 
			
		||||
		XmlBeanFactory parent = new XmlBeanFactory(PARENT_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
 | 
			
		||||
		TestBean beanFromParent = (TestBean) parent.getBean("inheritedTestBeanSingleton");
 | 
			
		||||
		XmlBeanFactory child = new XmlBeanFactory(CHILD_CONTEXT, parent);
 | 
			
		||||
		DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
 | 
			
		||||
		new XmlBeanDefinitionReader(child).loadBeanDefinitions(CHILD_CONTEXT);
 | 
			
		||||
		TestBean beanFromChild = (TestBean) child.getBean("inheritedTestBeanSingleton");
 | 
			
		||||
		assertTrue("singleton from parent and child is the same", beanFromParent == beanFromChild);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testNestedPropertyValue() {
 | 
			
		||||
		XmlBeanFactory parent = new XmlBeanFactory(PARENT_CONTEXT);
 | 
			
		||||
		XmlBeanFactory child = new XmlBeanFactory(CHILD_CONTEXT, parent);
 | 
			
		||||
		DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
 | 
			
		||||
		new XmlBeanDefinitionReader(child).loadBeanDefinitions(CHILD_CONTEXT);
 | 
			
		||||
		IndexedTestBean bean = (IndexedTestBean) child.getBean("indexedTestBean");
 | 
			
		||||
		assertEquals("name applied correctly", "myname", bean.getArray()[0].getName());
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -571,19 +593,22 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testFactoryReferenceCircle() {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(FACTORY_CIRCLE_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(FACTORY_CIRCLE_CONTEXT);
 | 
			
		||||
		TestBean tb = (TestBean) xbf.getBean("singletonFactory");
 | 
			
		||||
		DummyFactory db = (DummyFactory) xbf.getBean("&singletonFactory");
 | 
			
		||||
		assertTrue(tb == db.getOtherTestBean());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testFactoryReferenceWithDoublePrefix() {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(FACTORY_CIRCLE_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(FACTORY_CIRCLE_CONTEXT);
 | 
			
		||||
		assertThat(xbf.getBean("&&singletonFactory"), instanceOf(DummyFactory.class));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testComplexFactoryReferenceCircle() {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(COMPLEX_FACTORY_CIRCLE_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(COMPLEX_FACTORY_CIRCLE_CONTEXT);
 | 
			
		||||
		xbf.getBean("proxy1");
 | 
			
		||||
		// check that unused instances from autowiring got removed
 | 
			
		||||
		assertEquals(4, xbf.getSingletonCount());
 | 
			
		||||
| 
						 | 
				
			
			@ -594,7 +619,8 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
 | 
			
		||||
	public @Test void testNoSuchFactoryBeanMethod() {
 | 
			
		||||
		try {
 | 
			
		||||
			XmlBeanFactory xbf = new XmlBeanFactory(NO_SUCH_FACTORY_METHOD_CONTEXT);
 | 
			
		||||
			DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
			new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(NO_SUCH_FACTORY_METHOD_CONTEXT);
 | 
			
		||||
			assertNotNull(xbf.getBean("defaultTestBean"));
 | 
			
		||||
			fail("Should not get invalid bean");
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -604,7 +630,8 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testInitMethodIsInvoked() throws Exception {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(INITIALIZERS_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(INITIALIZERS_CONTEXT);
 | 
			
		||||
		DoubleInitializer in = (DoubleInitializer) xbf.getBean("init-method1");
 | 
			
		||||
		// Initializer should have doubled value
 | 
			
		||||
		assertEquals(14, in.getNum());
 | 
			
		||||
| 
						 | 
				
			
			@ -614,7 +641,8 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	 * Test that if a custom initializer throws an exception, it's handled correctly
 | 
			
		||||
	 */
 | 
			
		||||
	public @Test void testInitMethodThrowsException() {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(INITIALIZERS_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(INITIALIZERS_CONTEXT);
 | 
			
		||||
		try {
 | 
			
		||||
			xbf.getBean("init-method2");
 | 
			
		||||
			fail();
 | 
			
		||||
| 
						 | 
				
			
			@ -627,7 +655,8 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testNoSuchInitMethod() throws Exception {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(INITIALIZERS_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(INITIALIZERS_CONTEXT);
 | 
			
		||||
		try {
 | 
			
		||||
			xbf.getBean("init-method3");
 | 
			
		||||
			fail();
 | 
			
		||||
| 
						 | 
				
			
			@ -645,7 +674,8 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	 */
 | 
			
		||||
	public @Test void testInitializingBeanAndInitMethod() throws Exception {
 | 
			
		||||
		InitAndIB.constructed = false;
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(INITIALIZERS_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(INITIALIZERS_CONTEXT);
 | 
			
		||||
		assertFalse(InitAndIB.constructed);
 | 
			
		||||
		xbf.preInstantiateSingletons();
 | 
			
		||||
		assertFalse(InitAndIB.constructed);
 | 
			
		||||
| 
						 | 
				
			
			@ -664,7 +694,8 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	 */
 | 
			
		||||
	public @Test void testInitializingBeanAndSameInitMethod() throws Exception {
 | 
			
		||||
		InitAndIB.constructed = false;
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(INITIALIZERS_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(INITIALIZERS_CONTEXT);
 | 
			
		||||
		assertFalse(InitAndIB.constructed);
 | 
			
		||||
		xbf.preInstantiateSingletons();
 | 
			
		||||
		assertFalse(InitAndIB.constructed);
 | 
			
		||||
| 
						 | 
				
			
			@ -680,7 +711,8 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
 | 
			
		||||
	public @Test void testDefaultLazyInit() throws Exception {
 | 
			
		||||
		InitAndIB.constructed = false;
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(DEFAULT_LAZY_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(DEFAULT_LAZY_CONTEXT);
 | 
			
		||||
		assertFalse(InitAndIB.constructed);
 | 
			
		||||
		xbf.preInstantiateSingletons();
 | 
			
		||||
		assertTrue(InitAndIB.constructed);
 | 
			
		||||
| 
						 | 
				
			
			@ -693,8 +725,9 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testNoSuchXmlFile() throws Exception {
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		try {
 | 
			
		||||
			new XmlBeanFactory(MISSING_CONTEXT);
 | 
			
		||||
			new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(MISSING_CONTEXT);
 | 
			
		||||
			fail("Must not create factory from missing XML");
 | 
			
		||||
		}
 | 
			
		||||
		catch (BeanDefinitionStoreException expected) {
 | 
			
		||||
| 
						 | 
				
			
			@ -702,8 +735,9 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testInvalidXmlFile() throws Exception {
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		try {
 | 
			
		||||
			new XmlBeanFactory(INVALID_CONTEXT);
 | 
			
		||||
			new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(INVALID_CONTEXT);
 | 
			
		||||
			fail("Must not create factory from invalid XML");
 | 
			
		||||
		}
 | 
			
		||||
		catch (BeanDefinitionStoreException expected) {
 | 
			
		||||
| 
						 | 
				
			
			@ -711,8 +745,9 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testUnsatisfiedObjectDependencyCheck() throws Exception {
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		try {
 | 
			
		||||
			XmlBeanFactory xbf = new XmlBeanFactory(UNSATISFIED_OBJECT_DEP_CONTEXT);
 | 
			
		||||
			new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(UNSATISFIED_OBJECT_DEP_CONTEXT);
 | 
			
		||||
			xbf.getBean("a", DependenciesBean.class);
 | 
			
		||||
			fail("Must have thrown an UnsatisfiedDependencyException");
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -721,8 +756,9 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testUnsatisfiedSimpleDependencyCheck() throws Exception {
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		try {
 | 
			
		||||
			XmlBeanFactory xbf = new XmlBeanFactory(UNSATISFIED_SIMPLE_DEP_CONTEXT);
 | 
			
		||||
			new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(UNSATISFIED_SIMPLE_DEP_CONTEXT);
 | 
			
		||||
			xbf.getBean("a", DependenciesBean.class);
 | 
			
		||||
			fail("Must have thrown an UnsatisfiedDependencyException");
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -731,21 +767,24 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testSatisfiedObjectDependencyCheck() throws Exception {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(SATISFIED_OBJECT_DEP_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(SATISFIED_OBJECT_DEP_CONTEXT);
 | 
			
		||||
		DependenciesBean a = (DependenciesBean) xbf.getBean("a");
 | 
			
		||||
		assertNotNull(a.getSpouse());
 | 
			
		||||
		assertEquals(xbf, a.getBeanFactory());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testSatisfiedSimpleDependencyCheck() throws Exception {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(SATISFIED_SIMPLE_DEP_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(SATISFIED_SIMPLE_DEP_CONTEXT);
 | 
			
		||||
		DependenciesBean a = (DependenciesBean) xbf.getBean("a");
 | 
			
		||||
		assertEquals(a.getAge(), 33);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testUnsatisfiedAllDependencyCheck() throws Exception {
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		try {
 | 
			
		||||
			XmlBeanFactory xbf = new XmlBeanFactory(UNSATISFIED_ALL_DEP_CONTEXT);
 | 
			
		||||
			new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(UNSATISFIED_ALL_DEP_CONTEXT);
 | 
			
		||||
			xbf.getBean("a", DependenciesBean.class);
 | 
			
		||||
			fail("Must have thrown an UnsatisfiedDependencyException");
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -754,7 +793,8 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testSatisfiedAllDependencyCheck() throws Exception {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(SATISFIED_ALL_DEP_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(SATISFIED_ALL_DEP_CONTEXT);
 | 
			
		||||
		DependenciesBean a = (DependenciesBean) xbf.getBean("a");
 | 
			
		||||
		assertEquals(a.getAge(), 33);
 | 
			
		||||
		assertNotNull(a.getName());
 | 
			
		||||
| 
						 | 
				
			
			@ -762,23 +802,27 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testAutowire() throws Exception {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(AUTOWIRE_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(AUTOWIRE_CONTEXT);
 | 
			
		||||
		TestBean spouse = new TestBean("kerry", 0);
 | 
			
		||||
		xbf.registerSingleton("spouse", spouse);
 | 
			
		||||
		doTestAutowire(xbf);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testAutowireWithParent() throws Exception {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(AUTOWIRE_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(AUTOWIRE_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
 | 
			
		||||
		MutablePropertyValues pvs = new MutablePropertyValues();
 | 
			
		||||
		pvs.add("name", "kerry");
 | 
			
		||||
		lbf.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class, pvs));
 | 
			
		||||
		RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		bd.setPropertyValues(pvs);
 | 
			
		||||
		lbf.registerBeanDefinition("spouse", bd);
 | 
			
		||||
		xbf.setParentBeanFactory(lbf);
 | 
			
		||||
		doTestAutowire(xbf);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private void doTestAutowire(XmlBeanFactory xbf) throws Exception {
 | 
			
		||||
	private void doTestAutowire(DefaultListableBeanFactory xbf) throws Exception {
 | 
			
		||||
		DependenciesBean rod1 = (DependenciesBean) xbf.getBean("rod1");
 | 
			
		||||
		TestBean kerry = (TestBean) xbf.getBean("spouse");
 | 
			
		||||
		// should have been autowired
 | 
			
		||||
| 
						 | 
				
			
			@ -827,7 +871,8 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testAutowireWithDefault() throws Exception {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(DEFAULT_AUTOWIRE_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(DEFAULT_AUTOWIRE_CONTEXT);
 | 
			
		||||
 | 
			
		||||
		DependenciesBean rod1 = (DependenciesBean) xbf.getBean("rod1");
 | 
			
		||||
		// should have been autowired
 | 
			
		||||
| 
						 | 
				
			
			@ -848,7 +893,8 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testAutowireByConstructor() throws Exception {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		ConstructorDependenciesBean rod1 = (ConstructorDependenciesBean) xbf.getBean("rod1");
 | 
			
		||||
		TestBean kerry = (TestBean) xbf.getBean("kerry2");
 | 
			
		||||
		// should have been autowired
 | 
			
		||||
| 
						 | 
				
			
			@ -884,7 +930,8 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testAutowireByConstructorWithSimpleValues() throws Exception {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
 | 
			
		||||
		ConstructorDependenciesBean rod5 = (ConstructorDependenciesBean) xbf.getBean("rod5");
 | 
			
		||||
		TestBean kerry1 = (TestBean) xbf.getBean("kerry1");
 | 
			
		||||
| 
						 | 
				
			
			@ -912,7 +959,8 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testRelatedCausesFromConstructorResolution() {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
 | 
			
		||||
		try {
 | 
			
		||||
			xbf.getBean("rod2Accessor");
 | 
			
		||||
| 
						 | 
				
			
			@ -925,7 +973,8 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testConstructorArgResolution() {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		TestBean kerry1 = (TestBean) xbf.getBean("kerry1");
 | 
			
		||||
		TestBean kerry2 = (TestBean) xbf.getBean("kerry2");
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -972,7 +1021,8 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testPrototypeWithExplicitArguments() {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		SimpleConstructorArgBean cd1 = (SimpleConstructorArgBean) xbf.getBean("rod18");
 | 
			
		||||
		assertEquals(0, cd1.getAge());
 | 
			
		||||
		SimpleConstructorArgBean cd2 = (SimpleConstructorArgBean) xbf.getBean("rod18", 98);
 | 
			
		||||
| 
						 | 
				
			
			@ -986,13 +1036,15 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testConstructorArgWithSingleMatch() {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		File file = (File) xbf.getBean("file");
 | 
			
		||||
		assertEquals(File.separator + "test", file.getPath());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testThrowsExceptionOnTooManyArguments() throws Exception {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		try {
 | 
			
		||||
			xbf.getBean("rod7", ConstructorDependenciesBean.class);
 | 
			
		||||
			fail("Should have thrown BeanCreationException");
 | 
			
		||||
| 
						 | 
				
			
			@ -1002,7 +1054,8 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testThrowsExceptionOnAmbiguousResolution() throws Exception {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		try {
 | 
			
		||||
			xbf.getBean("rod8", ConstructorDependenciesBean.class);
 | 
			
		||||
			fail("Must have thrown UnsatisfiedDependencyException");
 | 
			
		||||
| 
						 | 
				
			
			@ -1058,7 +1111,8 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
		PreparingBean2.destroyed = false;
 | 
			
		||||
		DependingBean.destroyCount = 0;
 | 
			
		||||
		HoldingBean.destroyCount = 0;
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(resource);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(resource);
 | 
			
		||||
		xbf.preInstantiateSingletons();
 | 
			
		||||
		xbf.destroySingletons();
 | 
			
		||||
		assertTrue(PreparingBean1.prepared);
 | 
			
		||||
| 
						 | 
				
			
			@ -1078,7 +1132,8 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	 * must rather only be picked up when the bean is instantiated.
 | 
			
		||||
	 */
 | 
			
		||||
	public @Test void testClassNotFoundWithDefaultBeanClassLoader() {
 | 
			
		||||
		BeanFactory factory = new XmlBeanFactory(CLASS_NOT_FOUND_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(factory).loadBeanDefinitions(CLASS_NOT_FOUND_CONTEXT);
 | 
			
		||||
		// cool, no errors, so the rubbish class name in the bean def was not resolved
 | 
			
		||||
		try {
 | 
			
		||||
			// let's resolve the bean definition; must blow up
 | 
			
		||||
| 
						 | 
				
			
			@ -1100,7 +1155,8 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testResourceAndInputStream() throws IOException {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(RESOURCE_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(RESOURCE_CONTEXT);
 | 
			
		||||
		// comes from "resourceImport.xml"
 | 
			
		||||
		ResourceTestBean resource1 = (ResourceTestBean) xbf.getBean("resource1");
 | 
			
		||||
		// comes from "resource.xml"
 | 
			
		||||
| 
						 | 
				
			
			@ -1122,7 +1178,8 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testClassPathResourceWithImport() {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(RESOURCE_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(RESOURCE_CONTEXT);
 | 
			
		||||
		// comes from "resourceImport.xml"
 | 
			
		||||
		xbf.getBean("resource1", ResourceTestBean.class);
 | 
			
		||||
		// comes from "resource.xml"
 | 
			
		||||
| 
						 | 
				
			
			@ -1131,7 +1188,8 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
 | 
			
		||||
	public @Test void testUrlResourceWithImport() {
 | 
			
		||||
		URL url = getClass().getResource(RESOURCE_CONTEXT.getPath());
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(new UrlResource(url));
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(new UrlResource(url));
 | 
			
		||||
		// comes from "resourceImport.xml"
 | 
			
		||||
		xbf.getBean("resource1", ResourceTestBean.class);
 | 
			
		||||
		// comes from "resource.xml"
 | 
			
		||||
| 
						 | 
				
			
			@ -1140,7 +1198,8 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
 | 
			
		||||
	public @Test void testFileSystemResourceWithImport() throws URISyntaxException {
 | 
			
		||||
		String file = getClass().getResource(RESOURCE_CONTEXT.getPath()).toURI().getPath();
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(new FileSystemResource(file));
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(new FileSystemResource(file));
 | 
			
		||||
		// comes from "resourceImport.xml"
 | 
			
		||||
		xbf.getBean("resource1", ResourceTestBean.class);
 | 
			
		||||
		// comes from "resource.xml"
 | 
			
		||||
| 
						 | 
				
			
			@ -1148,8 +1207,9 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testRecursiveImport() {
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		try {
 | 
			
		||||
			new XmlBeanFactory(RECURSIVE_IMPORT_CONTEXT);
 | 
			
		||||
			new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(RECURSIVE_IMPORT_CONTEXT);
 | 
			
		||||
			fail("Should have thrown BeanDefinitionStoreException");
 | 
			
		||||
		}
 | 
			
		||||
		catch (BeanDefinitionStoreException ex) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1344,7 +1404,8 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testConstructorArgWithSingleSimpleTypeMatch() {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
 | 
			
		||||
		SingleSimpleTypeConstructorBean bean = (SingleSimpleTypeConstructorBean) xbf.getBean("beanWithBoolean");
 | 
			
		||||
		assertTrue(bean.isSingleBoolean());
 | 
			
		||||
| 
						 | 
				
			
			@ -1354,7 +1415,8 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testConstructorArgWithDoubleSimpleTypeMatch() {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
 | 
			
		||||
		SingleSimpleTypeConstructorBean bean = (SingleSimpleTypeConstructorBean) xbf.getBean("beanWithBooleanAndString");
 | 
			
		||||
		assertTrue(bean.isSecondBoolean());
 | 
			
		||||
| 
						 | 
				
			
			@ -1366,33 +1428,38 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testDoubleBooleanAutowire() {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		DoubleBooleanConstructorBean bean = (DoubleBooleanConstructorBean) xbf.getBean("beanWithDoubleBoolean");
 | 
			
		||||
		assertEquals(Boolean.TRUE, bean.boolean1);
 | 
			
		||||
		assertEquals(Boolean.FALSE, bean.boolean2);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testDoubleBooleanAutowireWithIndex() {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		DoubleBooleanConstructorBean bean = (DoubleBooleanConstructorBean) xbf.getBean("beanWithDoubleBooleanAndIndex");
 | 
			
		||||
		assertEquals(Boolean.FALSE, bean.boolean1);
 | 
			
		||||
		assertEquals(Boolean.TRUE, bean.boolean2);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testLenientDependencyMatching() {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		LenientDependencyTestBean bean = (LenientDependencyTestBean) xbf.getBean("lenientDependencyTestBean");
 | 
			
		||||
		assertTrue(bean.tb instanceof DerivedTestBean);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testLenientDependencyMatchingFactoryMethod() {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		LenientDependencyTestBean bean = (LenientDependencyTestBean) xbf.getBean("lenientDependencyTestBeanFactoryMethod");
 | 
			
		||||
		assertTrue(bean.tb instanceof DerivedTestBean);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testNonLenientDependencyMatching() {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		AbstractBeanDefinition bd = (AbstractBeanDefinition) xbf.getBeanDefinition("lenientDependencyTestBean");
 | 
			
		||||
		bd.setLenientConstructorResolution(false);
 | 
			
		||||
		try {
 | 
			
		||||
| 
						 | 
				
			
			@ -1407,7 +1474,8 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testNonLenientDependencyMatchingFactoryMethod() {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		AbstractBeanDefinition bd = (AbstractBeanDefinition) xbf.getBeanDefinition("lenientDependencyTestBeanFactoryMethod");
 | 
			
		||||
		bd.setLenientConstructorResolution(false);
 | 
			
		||||
		try {
 | 
			
		||||
| 
						 | 
				
			
			@ -1422,7 +1490,8 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testJavaLangStringConstructor() {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		AbstractBeanDefinition bd = (AbstractBeanDefinition) xbf.getBeanDefinition("string");
 | 
			
		||||
		bd.setLenientConstructorResolution(false);
 | 
			
		||||
		String str = (String) xbf.getBean("string");
 | 
			
		||||
| 
						 | 
				
			
			@ -1430,7 +1499,8 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testCustomStringConstructor() {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		AbstractBeanDefinition bd = (AbstractBeanDefinition) xbf.getBeanDefinition("stringConstructor");
 | 
			
		||||
		bd.setLenientConstructorResolution(false);
 | 
			
		||||
		StringConstructorTestBean tb = (StringConstructorTestBean) xbf.getBean("stringConstructor");
 | 
			
		||||
| 
						 | 
				
			
			@ -1438,7 +1508,8 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testPrimitiveConstructorArray() {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		ConstructorArrayTestBean bean = (ConstructorArrayTestBean) xbf.getBean("constructorArray");
 | 
			
		||||
		assertTrue(bean.array instanceof int[]);
 | 
			
		||||
		assertEquals(1, ((int[]) bean.array).length);
 | 
			
		||||
| 
						 | 
				
			
			@ -1446,7 +1517,8 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testIndexedPrimitiveConstructorArray() {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		ConstructorArrayTestBean bean = (ConstructorArrayTestBean) xbf.getBean("indexedConstructorArray");
 | 
			
		||||
		assertTrue(bean.array instanceof int[]);
 | 
			
		||||
		assertEquals(1, ((int[]) bean.array).length);
 | 
			
		||||
| 
						 | 
				
			
			@ -1454,14 +1526,16 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testStringConstructorArrayNoType() {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		ConstructorArrayTestBean bean = (ConstructorArrayTestBean) xbf.getBean("constructorArrayNoType");
 | 
			
		||||
		assertTrue(bean.array instanceof String[]);
 | 
			
		||||
		assertEquals(0, ((String[]) bean.array).length);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testStringConstructorArrayNoTypeNonLenient() {
 | 
			
		||||
		XmlBeanFactory xbf = new XmlBeanFactory(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
 | 
			
		||||
		AbstractBeanDefinition bd = (AbstractBeanDefinition) xbf.getBeanDefinition("constructorArrayNoType");
 | 
			
		||||
		bd.setLenientConstructorResolution(false);
 | 
			
		||||
		ConstructorArrayTestBean bean = (ConstructorArrayTestBean) xbf.getBean("constructorArrayNoType");
 | 
			
		||||
| 
						 | 
				
			
			@ -1470,8 +1544,9 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testWithDuplicateName() throws Exception {
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		try {
 | 
			
		||||
			new XmlBeanFactory(TEST_WITH_DUP_NAMES_CONTEXT);
 | 
			
		||||
			new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(TEST_WITH_DUP_NAMES_CONTEXT);
 | 
			
		||||
			fail("Duplicate name not detected");
 | 
			
		||||
		}
 | 
			
		||||
		catch (BeansException ex) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1480,8 +1555,9 @@ public final class XmlBeanFactoryTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public @Test void testWithDuplicateNameInAlias() throws Exception {
 | 
			
		||||
		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
 | 
			
		||||
		try {
 | 
			
		||||
			new XmlBeanFactory(TEST_WITH_DUP_NAME_IN_ALIAS_CONTEXT);
 | 
			
		||||
			new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(TEST_WITH_DUP_NAME_IN_ALIAS_CONTEXT);
 | 
			
		||||
			fail("Duplicate name not detected");
 | 
			
		||||
		}
 | 
			
		||||
		catch (BeansException e) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright 2010-2011 the original author or authors.
 | 
			
		||||
 * 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.
 | 
			
		||||
| 
						 | 
				
			
			@ -16,7 +16,7 @@
 | 
			
		|||
 | 
			
		||||
package org.springframework.cache.config;
 | 
			
		||||
 | 
			
		||||
import junit.framework.Assert;
 | 
			
		||||
import static org.junit.Assert.assertSame;
 | 
			
		||||
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import org.springframework.cache.interceptor.CacheInterceptor;
 | 
			
		||||
| 
						 | 
				
			
			@ -39,6 +39,6 @@ public class AnnotationNamespaceDrivenTests extends AbstractAnnotationTests {
 | 
			
		|||
	public void testKeyStrategy() throws Exception {
 | 
			
		||||
		CacheInterceptor ci = ctx.getBean("org.springframework.cache.interceptor.CacheInterceptor#0",
 | 
			
		||||
				CacheInterceptor.class);
 | 
			
		||||
		Assert.assertSame(ctx.getBean("keyGenerator"), ci.getKeyGenerator());
 | 
			
		||||
		assertSame(ctx.getBean("keyGenerator"), ci.getKeyGenerator());
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,12 +16,11 @@
 | 
			
		|||
 | 
			
		||||
package org.springframework.cache.config;
 | 
			
		||||
 | 
			
		||||
import static org.junit.Assert.assertSame;
 | 
			
		||||
import static org.junit.Assert.assertTrue;
 | 
			
		||||
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
 | 
			
		||||
import junit.framework.Assert;
 | 
			
		||||
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import org.springframework.beans.factory.BeanCreationException;
 | 
			
		||||
import org.springframework.cache.CacheManager;
 | 
			
		||||
| 
						 | 
				
			
			@ -53,7 +52,7 @@ public class EnableCachingTests extends AbstractAnnotationTests {
 | 
			
		|||
	@Test
 | 
			
		||||
	public void testKeyStrategy() throws Exception {
 | 
			
		||||
		CacheInterceptor ci = ctx.getBean(CacheInterceptor.class);
 | 
			
		||||
		Assert.assertSame(ctx.getBean(KeyGenerator.class), ci.getKeyGenerator());
 | 
			
		||||
		assertSame(ctx.getBean(KeyGenerator.class), ci.getKeyGenerator());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --- local tests -------
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,14 +16,16 @@
 | 
			
		|||
 | 
			
		||||
package org.springframework.context.access;
 | 
			
		||||
 | 
			
		||||
import static org.junit.Assert.*;
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import static org.junit.Assert.assertEquals;
 | 
			
		||||
import static org.junit.Assert.assertTrue;
 | 
			
		||||
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import org.springframework.beans.factory.BeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.access.BeanFactoryLocator;
 | 
			
		||||
import org.springframework.beans.factory.access.BeanFactoryReference;
 | 
			
		||||
import org.springframework.beans.factory.access.SingletonBeanFactoryLocatorTests;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 | 
			
		||||
import org.springframework.context.ApplicationContext;
 | 
			
		||||
import org.springframework.core.io.ClassPathResource;
 | 
			
		||||
import org.springframework.util.ClassUtils;
 | 
			
		||||
| 
						 | 
				
			
			@ -43,8 +45,10 @@ public class ContextSingletonBeanFactoryLocatorTests extends SingletonBeanFactor
 | 
			
		|||
	public void testBaseBeanFactoryDefs() {
 | 
			
		||||
		// Just test the base BeanFactory/AppContext defs we are going to work
 | 
			
		||||
		// with in other tests.
 | 
			
		||||
		new XmlBeanFactory(new ClassPathResource("/org/springframework/beans/factory/access/beans1.xml"));
 | 
			
		||||
		new XmlBeanFactory(new ClassPathResource("/org/springframework/beans/factory/access/beans2.xml"));
 | 
			
		||||
		new XmlBeanDefinitionReader(new DefaultListableBeanFactory()).loadBeanDefinitions(new ClassPathResource(
 | 
			
		||||
				"/org/springframework/beans/factory/access/beans1.xml"));
 | 
			
		||||
		new XmlBeanDefinitionReader(new DefaultListableBeanFactory()).loadBeanDefinitions(new ClassPathResource(
 | 
			
		||||
				"/org/springframework/beans/factory/access/beans2.xml"));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,8 +31,8 @@ import org.springframework.beans.factory.annotation.Required;
 | 
			
		|||
import org.springframework.beans.factory.config.RuntimeBeanReference;
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.support.RootBeanDefinition;
 | 
			
		||||
import org.springframework.build.junit.Assume;
 | 
			
		||||
import org.springframework.build.junit.TestGroup;
 | 
			
		||||
import org.springframework.tests.Assume;
 | 
			
		||||
import org.springframework.tests.TestGroup;
 | 
			
		||||
import org.springframework.context.support.GenericApplicationContext;
 | 
			
		||||
import org.springframework.util.StopWatch;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -34,6 +34,7 @@ import org.springframework.beans.factory.BeanFactory;
 | 
			
		|||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
 | 
			
		||||
import org.springframework.beans.factory.ObjectFactory;
 | 
			
		||||
import org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor;
 | 
			
		||||
import org.springframework.beans.factory.config.BeanDefinition;
 | 
			
		||||
import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor;
 | 
			
		||||
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
| 
						 | 
				
			
			@ -171,9 +172,15 @@ public class CommonAnnotationBeanPostProcessorTests {
 | 
			
		|||
		CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor();
 | 
			
		||||
		bpp.setResourceFactory(bf);
 | 
			
		||||
		bf.addBeanPostProcessor(bpp);
 | 
			
		||||
		bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ResourceInjectionBean.class, false));
 | 
			
		||||
		bf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class, false));
 | 
			
		||||
		bf.registerBeanDefinition("testBean2", new RootBeanDefinition(TestBean.class, false));
 | 
			
		||||
		RootBeanDefinition abd = new RootBeanDefinition(ResourceInjectionBean.class);
 | 
			
		||||
		abd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
 | 
			
		||||
		bf.registerBeanDefinition("annotatedBean", abd);
 | 
			
		||||
		RootBeanDefinition tbd1 = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		tbd1.setScope(BeanDefinition.SCOPE_PROTOTYPE);
 | 
			
		||||
		bf.registerBeanDefinition("testBean", tbd1);
 | 
			
		||||
		RootBeanDefinition tbd2 = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		tbd2.setScope(BeanDefinition.SCOPE_PROTOTYPE);
 | 
			
		||||
		bf.registerBeanDefinition("testBean2", tbd2);
 | 
			
		||||
 | 
			
		||||
		ResourceInjectionBean bean = (ResourceInjectionBean) bf.getBean("annotatedBean");
 | 
			
		||||
		assertTrue(bean.initCalled);
 | 
			
		||||
| 
						 | 
				
			
			@ -202,8 +209,12 @@ public class CommonAnnotationBeanPostProcessorTests {
 | 
			
		|||
		CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor();
 | 
			
		||||
		bpp.setBeanFactory(bf);
 | 
			
		||||
		bf.addBeanPostProcessor(bpp);
 | 
			
		||||
		bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ExtendedResourceInjectionBean.class, false));
 | 
			
		||||
		bf.registerBeanDefinition("testBean4", new RootBeanDefinition(TestBean.class, false));
 | 
			
		||||
		RootBeanDefinition abd = new RootBeanDefinition(ExtendedResourceInjectionBean.class);
 | 
			
		||||
		abd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
 | 
			
		||||
		bf.registerBeanDefinition("annotatedBean", abd);
 | 
			
		||||
		RootBeanDefinition tbd = new RootBeanDefinition(TestBean.class);
 | 
			
		||||
		tbd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
 | 
			
		||||
		bf.registerBeanDefinition("testBean4", tbd);
 | 
			
		||||
 | 
			
		||||
		bf.registerResolvableDependency(BeanFactory.class, bf);
 | 
			
		||||
		bf.registerResolvableDependency(INestedTestBean.class, new ObjectFactory<Object>() {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -25,8 +25,9 @@ import test.beans.TestBean;
 | 
			
		|||
import org.springframework.beans.factory.BeanCreationException;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Value;
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.support.RootBeanDefinition;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 | 
			
		||||
import org.springframework.context.annotation.Bean;
 | 
			
		||||
import org.springframework.context.annotation.Configuration;
 | 
			
		||||
import org.springframework.context.annotation.Scope;
 | 
			
		||||
| 
						 | 
				
			
			@ -79,7 +80,9 @@ public class AutowiredConfigurationTests {
 | 
			
		|||
	 */
 | 
			
		||||
	@Test(expected=BeanCreationException.class)
 | 
			
		||||
	public void testAutowiredConfigurationConstructorsAreNotSupported() {
 | 
			
		||||
		XmlBeanFactory factory = new XmlBeanFactory(new ClassPathResource("annotation-config.xml", AutowiredConstructorConfig.class));
 | 
			
		||||
		DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(factory).loadBeanDefinitions(
 | 
			
		||||
				new ClassPathResource("annotation-config.xml", AutowiredConstructorConfig.class));
 | 
			
		||||
		GenericApplicationContext ctx = new GenericApplicationContext(factory);
 | 
			
		||||
		ctx.registerBeanDefinition("config1", new RootBeanDefinition(AutowiredConstructorConfig.class));
 | 
			
		||||
		ctx.registerBeanDefinition("config2", new RootBeanDefinition(ColorConfig.class));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,14 +16,15 @@
 | 
			
		|||
 | 
			
		||||
package org.springframework.context.annotation.configuration;
 | 
			
		||||
 | 
			
		||||
import static org.hamcrest.CoreMatchers.*;
 | 
			
		||||
import static org.junit.Assert.*;
 | 
			
		||||
import static org.hamcrest.CoreMatchers.equalTo;
 | 
			
		||||
import static org.junit.Assert.assertThat;
 | 
			
		||||
 | 
			
		||||
import org.aspectj.lang.annotation.Aspect;
 | 
			
		||||
import org.aspectj.lang.annotation.Before;
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.support.RootBeanDefinition;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 | 
			
		||||
import org.springframework.context.annotation.Bean;
 | 
			
		||||
import org.springframework.context.annotation.Configuration;
 | 
			
		||||
import org.springframework.context.annotation.ConfigurationClassPostProcessor;
 | 
			
		||||
| 
						 | 
				
			
			@ -47,8 +48,10 @@ import test.beans.TestBean;
 | 
			
		|||
 */
 | 
			
		||||
public class ConfigurationClassAspectIntegrationTests {
 | 
			
		||||
	private void assertAdviceWasApplied(Class<?> configClass) {
 | 
			
		||||
		GenericApplicationContext ctx = new GenericApplicationContext(
 | 
			
		||||
					new XmlBeanFactory(new ClassPathResource("aspectj-autoproxy-config.xml", ConfigurationClassAspectIntegrationTests.class)));
 | 
			
		||||
		DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(factory).loadBeanDefinitions(
 | 
			
		||||
				new ClassPathResource("aspectj-autoproxy-config.xml", ConfigurationClassAspectIntegrationTests.class));
 | 
			
		||||
		GenericApplicationContext ctx = new GenericApplicationContext(factory);
 | 
			
		||||
		ctx.addBeanFactoryPostProcessor(new ConfigurationClassPostProcessor());
 | 
			
		||||
		ctx.registerBeanDefinition("config", new RootBeanDefinition(configClass));
 | 
			
		||||
		ctx.refresh();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -86,7 +86,7 @@ public class EventPublicationInterceptorTests {
 | 
			
		|||
		class TestContext extends StaticApplicationContext {
 | 
			
		||||
			@Override
 | 
			
		||||
			protected void onRefresh() throws BeansException {
 | 
			
		||||
				addListener(listener);
 | 
			
		||||
				addApplicationListener(listener);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -38,8 +38,8 @@ import org.springframework.beans.factory.support.AutowireCandidateQualifier;
 | 
			
		|||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.support.GenericBeanDefinition;
 | 
			
		||||
import org.springframework.beans.factory.support.RootBeanDefinition;
 | 
			
		||||
import org.springframework.build.junit.Assume;
 | 
			
		||||
import org.springframework.build.junit.TestGroup;
 | 
			
		||||
import org.springframework.tests.Assume;
 | 
			
		||||
import org.springframework.tests.TestGroup;
 | 
			
		||||
import org.springframework.context.annotation.AnnotationConfigUtils;
 | 
			
		||||
import org.springframework.context.support.GenericApplicationContext;
 | 
			
		||||
import org.springframework.util.SerializationTestUtils;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -54,7 +54,7 @@ public class StaticApplicationContextMulticasterTests extends AbstractApplicatio
 | 
			
		|||
		parent.registerSingleton(StaticApplicationContext.APPLICATION_EVENT_MULTICASTER_BEAN_NAME,
 | 
			
		||||
				TestApplicationEventMulticaster.class, null);
 | 
			
		||||
		parent.refresh();
 | 
			
		||||
		parent.addListener(parentListener) ;
 | 
			
		||||
		parent.addApplicationListener(parentListener) ;
 | 
			
		||||
 | 
			
		||||
		parent.getStaticMessageSource().addMessage("code1", Locale.getDefault(), "message1");
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -66,7 +66,7 @@ public class StaticApplicationContextMulticasterTests extends AbstractApplicatio
 | 
			
		|||
		Resource resource = new ClassPathResource("testBeans.properties", getClass());
 | 
			
		||||
		reader.loadBeanDefinitions(new EncodedResource(resource, "ISO-8859-1"));
 | 
			
		||||
		sac.refresh();
 | 
			
		||||
		sac.addListener(listener);
 | 
			
		||||
		sac.addApplicationListener(listener);
 | 
			
		||||
 | 
			
		||||
		sac.getStaticMessageSource().addMessage("code2", Locale.getDefault(), "message2");
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -48,7 +48,7 @@ public class StaticApplicationContextTests extends AbstractApplicationContextTes
 | 
			
		|||
		m.put("name", "Albert");
 | 
			
		||||
		parent.registerPrototype("father", TestBean.class, new MutablePropertyValues(m));
 | 
			
		||||
		parent.refresh();
 | 
			
		||||
		parent.addListener(parentListener) ;
 | 
			
		||||
		parent.addApplicationListener(parentListener) ;
 | 
			
		||||
 | 
			
		||||
		parent.getStaticMessageSource().addMessage("code1", Locale.getDefault(), "message1");
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -59,7 +59,7 @@ public class StaticApplicationContextTests extends AbstractApplicationContextTes
 | 
			
		|||
		PropertiesBeanDefinitionReader reader = new PropertiesBeanDefinitionReader(sac.getDefaultListableBeanFactory());
 | 
			
		||||
		reader.loadBeanDefinitions(new ClassPathResource("testBeans.properties", getClass()));
 | 
			
		||||
		sac.refresh();
 | 
			
		||||
		sac.addListener(listener);
 | 
			
		||||
		sac.addApplicationListener(listener);
 | 
			
		||||
 | 
			
		||||
		sac.getStaticMessageSource().addMessage("code2", Locale.getDefault(), "message2");
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -208,7 +208,7 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests {
 | 
			
		|||
		parent.registerPrototype("father", org.springframework.beans.TestBean.class, new MutablePropertyValues(m));
 | 
			
		||||
 | 
			
		||||
		parent.refresh();
 | 
			
		||||
		parent.addListener(parentListener);
 | 
			
		||||
		parent.addApplicationListener(parentListener);
 | 
			
		||||
 | 
			
		||||
		this.sac = new StaticApplicationContext(parent);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -221,7 +221,7 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests {
 | 
			
		|||
		PropertiesBeanDefinitionReader reader = new PropertiesBeanDefinitionReader(sac.getDefaultListableBeanFactory());
 | 
			
		||||
		reader.loadBeanDefinitions(new ClassPathResource("testBeans.properties", getClass()));
 | 
			
		||||
		sac.refresh();
 | 
			
		||||
		sac.addListener(listener);
 | 
			
		||||
		sac.addApplicationListener(listener);
 | 
			
		||||
 | 
			
		||||
		StaticMessageSource messageSource = sac.getStaticMessageSource();
 | 
			
		||||
		Map<String, String> usMessages = new HashMap<String, String>(3);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -36,6 +36,7 @@ import org.springframework.beans.BeanUtils;
 | 
			
		|||
import org.springframework.beans.ConfigurablePropertyAccessor;
 | 
			
		||||
import org.springframework.beans.PropertyAccessorFactory;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Value;
 | 
			
		||||
import org.springframework.beans.factory.config.BeanDefinition;
 | 
			
		||||
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
 | 
			
		||||
import org.springframework.beans.factory.support.RootBeanDefinition;
 | 
			
		||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
 | 
			
		||||
| 
						 | 
				
			
			@ -112,7 +113,9 @@ public class FormattingConversionServiceTests {
 | 
			
		|||
	@Test
 | 
			
		||||
	public void testFormatFieldForValueInjectionUsingMetaAnnotations() {
 | 
			
		||||
		AnnotationConfigApplicationContext ac = new AnnotationConfigApplicationContext();
 | 
			
		||||
		ac.registerBeanDefinition("valueBean", new RootBeanDefinition(MetaValueBean.class, false));
 | 
			
		||||
		RootBeanDefinition bd = new RootBeanDefinition(MetaValueBean.class);
 | 
			
		||||
		bd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
 | 
			
		||||
		ac.registerBeanDefinition("valueBean", bd);
 | 
			
		||||
		ac.registerBeanDefinition("conversionService", new RootBeanDefinition(FormattingConversionServiceFactoryBean.class));
 | 
			
		||||
		ac.registerBeanDefinition("ppc", new RootBeanDefinition(PropertyPlaceholderConfigurer.class));
 | 
			
		||||
		ac.refresh();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -37,7 +37,7 @@ import org.springframework.aop.framework.ProxyFactory;
 | 
			
		|||
import org.springframework.beans.TestBean;
 | 
			
		||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
 | 
			
		||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
 | 
			
		||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 | 
			
		||||
import org.springframework.core.io.ClassPathResource;
 | 
			
		||||
import org.springframework.jmx.AbstractMBeanServerTests;
 | 
			
		||||
import org.springframework.jmx.IJmxTestBean;
 | 
			
		||||
| 
						 | 
				
			
			@ -155,7 +155,8 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public void testAutodetectMBeans() throws Exception {
 | 
			
		||||
		XmlBeanFactory bf = new XmlBeanFactory(new ClassPathResource("autodetectMBeans.xml", getClass()));
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource("autodetectMBeans.xml", getClass()));
 | 
			
		||||
		try {
 | 
			
		||||
			bf.getBean("exporter");
 | 
			
		||||
			MBeanServer server = (MBeanServer) bf.getBean("server");
 | 
			
		||||
| 
						 | 
				
			
			@ -171,7 +172,8 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public void testAutodetectWithExclude() throws Exception {
 | 
			
		||||
		XmlBeanFactory bf = new XmlBeanFactory(new ClassPathResource("autodetectMBeans.xml", getClass()));
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource("autodetectMBeans.xml", getClass()));
 | 
			
		||||
		try {
 | 
			
		||||
			bf.getBean("exporter");
 | 
			
		||||
			MBeanServer server = (MBeanServer) bf.getBean("server");
 | 
			
		||||
| 
						 | 
				
			
			@ -189,7 +191,8 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public void testAutodetectLazyMBeans() throws Exception {
 | 
			
		||||
		XmlBeanFactory bf = new XmlBeanFactory(new ClassPathResource("autodetectLazyMBeans.xml", getClass()));
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource("autodetectLazyMBeans.xml", getClass()));
 | 
			
		||||
		try {
 | 
			
		||||
			bf.getBean("exporter");
 | 
			
		||||
			MBeanServer server = (MBeanServer) bf.getBean("server");
 | 
			
		||||
| 
						 | 
				
			
			@ -209,7 +212,8 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public void testAutodetectNoMBeans() throws Exception {
 | 
			
		||||
		XmlBeanFactory bf = new XmlBeanFactory(new ClassPathResource("autodetectNoMBeans.xml", getClass()));
 | 
			
		||||
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
 | 
			
		||||
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource("autodetectNoMBeans.xml", getClass()));
 | 
			
		||||
		try {
 | 
			
		||||
			bf.getBean("exporter");
 | 
			
		||||
		} finally {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,8 +22,8 @@ import java.util.concurrent.atomic.AtomicInteger;
 | 
			
		|||
import org.junit.Before;
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
 | 
			
		||||
import org.springframework.build.junit.Assume;
 | 
			
		||||
import org.springframework.build.junit.TestGroup;
 | 
			
		||||
import org.springframework.tests.Assume;
 | 
			
		||||
import org.springframework.tests.TestGroup;
 | 
			
		||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
 | 
			
		||||
import org.springframework.context.annotation.Bean;
 | 
			
		||||
import org.springframework.context.annotation.Configuration;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright 2002-2007 the original author or authors.
 | 
			
		||||
 * 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.
 | 
			
		||||
| 
						 | 
				
			
			@ -24,6 +24,7 @@ import org.springframework.core.task.NoOpRunnable;
 | 
			
		|||
 * @author Rick Evans
 | 
			
		||||
 * @author Juergen Hoeller
 | 
			
		||||
 */
 | 
			
		||||
@Deprecated
 | 
			
		||||
public class ConcurrentTaskExecutorTests extends TestCase {
 | 
			
		||||
 | 
			
		||||
	public void testZeroArgCtorResultsInDefaultTaskExecutorBeingUsed() throws Exception {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,6 +29,7 @@ import org.springframework.scheduling.TestMethodInvokingTask;
 | 
			
		|||
 * @author Juergen Hoeller
 | 
			
		||||
 * @since 20.02.2004
 | 
			
		||||
 */
 | 
			
		||||
@Deprecated
 | 
			
		||||
public class TimerSupportTests extends TestCase {
 | 
			
		||||
 | 
			
		||||
	public void testTimerFactoryBean() throws Exception {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -28,6 +28,7 @@ import org.junit.Test;
 | 
			
		|||
 * @author Rick Evans
 | 
			
		||||
 * @author Chris Beams
 | 
			
		||||
 */
 | 
			
		||||
@Deprecated
 | 
			
		||||
public final class TimerTaskExecutorTests {
 | 
			
		||||
 | 
			
		||||
	@Test(expected=IllegalArgumentException.class)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,7 +19,6 @@ package org.springframework.scripting.jruby;
 | 
			
		|||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
import junit.framework.TestCase;
 | 
			
		||||
import junit.framework.Assert;
 | 
			
		||||
 | 
			
		||||
import org.springframework.aop.support.AopUtils;
 | 
			
		||||
import org.springframework.aop.target.dynamic.Refreshable;
 | 
			
		||||
| 
						 | 
				
			
			@ -55,14 +54,14 @@ public class JRubyScriptFactoryTests extends TestCase {
 | 
			
		|||
		assertFalse("Scripted object should not be instance of Refreshable", calc instanceof Refreshable);
 | 
			
		||||
		assertFalse("Scripted object should not be instance of Refreshable", messenger instanceof Refreshable);
 | 
			
		||||
 | 
			
		||||
		Assert.assertEquals(calc, calc);
 | 
			
		||||
		Assert.assertEquals(messenger, messenger);
 | 
			
		||||
		assertEquals(calc, calc);
 | 
			
		||||
		assertEquals(messenger, messenger);
 | 
			
		||||
		assertTrue(!messenger.equals(calc));
 | 
			
		||||
		assertNotSame(messenger.hashCode(), calc.hashCode());
 | 
			
		||||
		assertTrue(!messenger.toString().equals(calc.toString()));
 | 
			
		||||
 | 
			
		||||
		String desiredMessage = "Hello World!";
 | 
			
		||||
		Assert.assertEquals("Message is incorrect", desiredMessage, messenger.getMessage());
 | 
			
		||||
		assertEquals("Message is incorrect", desiredMessage, messenger.getMessage());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void testNonStaticScript() throws Exception {
 | 
			
		||||
| 
						 | 
				
			
			@ -73,12 +72,12 @@ public class JRubyScriptFactoryTests extends TestCase {
 | 
			
		|||
		assertTrue("Should be an instance of Refreshable", messenger instanceof Refreshable);
 | 
			
		||||
 | 
			
		||||
		String desiredMessage = "Hello World!";
 | 
			
		||||
		Assert.assertEquals("Message is incorrect.", desiredMessage, messenger.getMessage());
 | 
			
		||||
		assertEquals("Message is incorrect.", desiredMessage, messenger.getMessage());
 | 
			
		||||
 | 
			
		||||
		Refreshable refreshable = (Refreshable) messenger;
 | 
			
		||||
		refreshable.refresh();
 | 
			
		||||
 | 
			
		||||
		Assert.assertEquals("Message is incorrect after refresh.", desiredMessage, messenger.getMessage());
 | 
			
		||||
		assertEquals("Message is incorrect after refresh.", desiredMessage, messenger.getMessage());
 | 
			
		||||
		assertEquals("Incorrect refresh count", 2, refreshable.getRefreshCount());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -142,14 +141,14 @@ public class JRubyScriptFactoryTests extends TestCase {
 | 
			
		|||
		TestBean testBean = (TestBean) ctx.getBean("testBean");
 | 
			
		||||
 | 
			
		||||
		Messenger messenger = (Messenger) ctx.getBean("messenger");
 | 
			
		||||
		Assert.assertEquals("Hello World!", messenger.getMessage());
 | 
			
		||||
		assertEquals("Hello World!", messenger.getMessage());
 | 
			
		||||
		assertFalse(messenger instanceof Refreshable);
 | 
			
		||||
 | 
			
		||||
		TestBeanAwareMessenger messengerByType = (TestBeanAwareMessenger) ctx.getBean("messengerByType");
 | 
			
		||||
		Assert.assertEquals(testBean, messengerByType.getTestBean());
 | 
			
		||||
		assertEquals(testBean, messengerByType.getTestBean());
 | 
			
		||||
 | 
			
		||||
		TestBeanAwareMessenger messengerByName = (TestBeanAwareMessenger) ctx.getBean("messengerByName");
 | 
			
		||||
		Assert.assertEquals(testBean, messengerByName.getTestBean());
 | 
			
		||||
		assertEquals(testBean, messengerByName.getTestBean());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void testPrototypeScriptFromTag() throws Exception {
 | 
			
		||||
| 
						 | 
				
			
			@ -159,12 +158,12 @@ public class JRubyScriptFactoryTests extends TestCase {
 | 
			
		|||
 | 
			
		||||
		assertNotSame(messenger, messenger2);
 | 
			
		||||
		assertSame(messenger.getClass(), messenger2.getClass());
 | 
			
		||||
		Assert.assertEquals("Hello World!", messenger.getMessage());
 | 
			
		||||
		Assert.assertEquals("Hello World!", messenger2.getMessage());
 | 
			
		||||
		assertEquals("Hello World!", messenger.getMessage());
 | 
			
		||||
		assertEquals("Hello World!", messenger2.getMessage());
 | 
			
		||||
		messenger.setMessage("Bye World!");
 | 
			
		||||
		messenger2.setMessage("Byebye World!");
 | 
			
		||||
		Assert.assertEquals("Bye World!", messenger.getMessage());
 | 
			
		||||
		Assert.assertEquals("Byebye World!", messenger2.getMessage());
 | 
			
		||||
		assertEquals("Bye World!", messenger.getMessage());
 | 
			
		||||
		assertEquals("Byebye World!", messenger2.getMessage());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void testInlineScriptFromTag() throws Exception {
 | 
			
		||||
| 
						 | 
				
			
			@ -177,18 +176,18 @@ public class JRubyScriptFactoryTests extends TestCase {
 | 
			
		|||
	public void testRefreshableFromTag() throws Exception {
 | 
			
		||||
		ApplicationContext ctx = new ClassPathXmlApplicationContext("jruby-with-xsd.xml", getClass());
 | 
			
		||||
		Messenger messenger = (Messenger) ctx.getBean("refreshableMessenger");
 | 
			
		||||
		Assert.assertEquals("Hello World!", messenger.getMessage());
 | 
			
		||||
		assertEquals("Hello World!", messenger.getMessage());
 | 
			
		||||
		assertTrue("Messenger should be Refreshable", messenger instanceof Refreshable);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void testThatMultipleScriptInterfacesAreSupported() throws Exception {
 | 
			
		||||
		ApplicationContext ctx = new ClassPathXmlApplicationContext("jruby-with-xsd.xml", getClass());
 | 
			
		||||
		Messenger messenger = (Messenger) ctx.getBean("calculatingMessenger");
 | 
			
		||||
		Assert.assertEquals("Hello World!", messenger.getMessage());
 | 
			
		||||
		assertEquals("Hello World!", messenger.getMessage());
 | 
			
		||||
 | 
			
		||||
		// cool, now check that the Calculator interface is also exposed
 | 
			
		||||
		Calculator calc = (Calculator) messenger;
 | 
			
		||||
		Assert.assertEquals(0, calc.add(2, -2));
 | 
			
		||||
		assertEquals(0, calc.add(2, -2));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void testWithComplexArg() throws Exception {
 | 
			
		||||
| 
						 | 
				
			
			@ -270,7 +269,7 @@ public class JRubyScriptFactoryTests extends TestCase {
 | 
			
		|||
	public void testAOP() throws Exception {
 | 
			
		||||
		ApplicationContext ctx = new ClassPathXmlApplicationContext("jruby-aop.xml", getClass());
 | 
			
		||||
		Messenger messenger = (Messenger) ctx.getBean("messenger");
 | 
			
		||||
		Assert.assertEquals(new StringBuffer("Hello World!").reverse().toString(), messenger.getMessage());
 | 
			
		||||
		assertEquals(new StringBuffer("Hello World!").reverse().toString(), messenger.getMessage());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -205,7 +205,7 @@ public class ScriptFactoryPostProcessorTests extends TestCase {
 | 
			
		|||
		ctx.registerBeanDefinition("messenger", BeanDefinitionBuilder.rootBeanDefinition(StubMessenger.class).getBeanDefinition());
 | 
			
		||||
 | 
			
		||||
		BeanDefinitionBuilder scriptedBeanBuilder = BeanDefinitionBuilder.rootBeanDefinition(GroovyScriptFactory.class);
 | 
			
		||||
		scriptedBeanBuilder.setSingleton(false);
 | 
			
		||||
		scriptedBeanBuilder.setScope(BeanDefinition.SCOPE_PROTOTYPE);
 | 
			
		||||
		scriptedBeanBuilder.addConstructorArgValue(DELEGATING_SCRIPT);
 | 
			
		||||
		scriptedBeanBuilder.addPropertyReference("messenger", "messenger");
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,7 +20,6 @@ import java.beans.PropertyEditorSupport;
 | 
			
		|||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
import junit.framework.TestCase;
 | 
			
		||||
import junit.framework.Assert;
 | 
			
		||||
 | 
			
		||||
import org.springframework.beans.FieldAccessBean;
 | 
			
		||||
import org.springframework.beans.MutablePropertyValues;
 | 
			
		||||
| 
						 | 
				
			
			@ -106,7 +105,7 @@ public class DataBinderFieldAccessTests extends TestCase {
 | 
			
		|||
			assertTrue("Correct number of age errors", br.getFieldErrorCount("age") == 1);
 | 
			
		||||
			assertEquals("32x", binder.getBindingResult().getFieldValue("age"));
 | 
			
		||||
			assertEquals("32x", binder.getBindingResult().getFieldError("age").getRejectedValue());
 | 
			
		||||
			Assert.assertEquals(0, tb.getAge());
 | 
			
		||||
			assertEquals(0, tb.getAge());
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -152,7 +151,7 @@ public class DataBinderFieldAccessTests extends TestCase {
 | 
			
		|||
			assertTrue("Correct number of age errors", br.getFieldErrorCount("age") == 1);
 | 
			
		||||
			assertEquals("32x", binder.getBindingResult().getFieldValue("age"));
 | 
			
		||||
			assertEquals("32x", binder.getBindingResult().getFieldError("age").getRejectedValue());
 | 
			
		||||
			Assert.assertEquals(0, tb.getAge());
 | 
			
		||||
			assertEquals(0, tb.getAge());
 | 
			
		||||
 | 
			
		||||
			assertTrue("Does not have spouse errors", !br.hasFieldErrors("spouse"));
 | 
			
		||||
			assertEquals("Kerry", binder.getBindingResult().getFieldValue("spouse"));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -33,21 +33,25 @@ import org.springframework.util.MultiValueMap;
 | 
			
		|||
 */
 | 
			
		||||
public class CollectionFactoryTests extends TestCase {
 | 
			
		||||
 | 
			
		||||
	@SuppressWarnings("deprecation")
 | 
			
		||||
	public void testLinkedSet() {
 | 
			
		||||
		Set set = CollectionFactory.createLinkedSetIfPossible(16);
 | 
			
		||||
		assertTrue(set instanceof LinkedHashSet);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@SuppressWarnings("deprecation")
 | 
			
		||||
	public void testLinkedMap() {
 | 
			
		||||
		Map map = CollectionFactory.createLinkedMapIfPossible(16);
 | 
			
		||||
		assertTrue(map instanceof LinkedHashMap);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@SuppressWarnings("deprecation")
 | 
			
		||||
	public void testIdentityMap() {
 | 
			
		||||
		Map map = CollectionFactory.createIdentityMapIfPossible(16);
 | 
			
		||||
		assertTrue(map instanceof IdentityHashMap);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@SuppressWarnings("deprecation")
 | 
			
		||||
	public void testConcurrentMap() {
 | 
			
		||||
		Map map = CollectionFactory.createConcurrentMapIfPossible(16);
 | 
			
		||||
		assertTrue(map.getClass().getName().endsWith("ConcurrentHashMap"));
 | 
			
		||||
| 
						 | 
				
			
			@ -58,6 +62,7 @@ public class CollectionFactoryTests extends TestCase {
 | 
			
		|||
		assertTrue(map.getClass().getName().endsWith("MultiValueMap"));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@SuppressWarnings("deprecation")
 | 
			
		||||
	public void testConcurrentMapWithExplicitInterface() {
 | 
			
		||||
		ConcurrentMap map = CollectionFactory.createConcurrentMap(16);
 | 
			
		||||
		assertTrue(map.getClass().getSuperclass().getName().endsWith("ConcurrentHashMap"));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -25,8 +25,6 @@ import java.util.List;
 | 
			
		|||
import java.util.Map;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
import junit.framework.Assert;
 | 
			
		||||
 | 
			
		||||
import org.springframework.beans.GenericBean;
 | 
			
		||||
import org.springframework.core.io.Resource;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -96,11 +94,11 @@ public class GenericCollectionTypeResolverTests extends AbstractGenericsTests {
 | 
			
		|||
 | 
			
		||||
	public void testProgrammaticListIntrospection() throws Exception {
 | 
			
		||||
		Method setter = GenericBean.class.getMethod("setResourceList", List.class);
 | 
			
		||||
		Assert.assertEquals(Resource.class,
 | 
			
		||||
		assertEquals(Resource.class,
 | 
			
		||||
				GenericCollectionTypeResolver.getCollectionParameterType(new MethodParameter(setter, 0)));
 | 
			
		||||
 | 
			
		||||
		Method getter = GenericBean.class.getMethod("getResourceList");
 | 
			
		||||
		Assert.assertEquals(Resource.class,
 | 
			
		||||
		assertEquals(Resource.class,
 | 
			
		||||
				GenericCollectionTypeResolver.getCollectionReturnType(getter));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,7 +20,6 @@ import java.io.ByteArrayOutputStream;
 | 
			
		|||
import java.io.PrintWriter;
 | 
			
		||||
 | 
			
		||||
import junit.framework.TestCase;
 | 
			
		||||
import junit.framework.Assert;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Rod Johnson
 | 
			
		||||
| 
						 | 
				
			
			@ -52,7 +51,7 @@ public class NestedExceptionTests extends TestCase {
 | 
			
		|||
		Exception rootCause = new Exception(rootCauseMesg);
 | 
			
		||||
		// Making a class abstract doesn't _really_ prevent instantiation :-)
 | 
			
		||||
		NestedRuntimeException nex = new NestedRuntimeException(myMessage, rootCause) {};
 | 
			
		||||
		Assert.assertEquals(nex.getCause(), rootCause);
 | 
			
		||||
		assertEquals(nex.getCause(), rootCause);
 | 
			
		||||
		assertTrue(nex.getMessage().indexOf(myMessage) != -1);
 | 
			
		||||
		assertTrue(nex.getMessage().indexOf(rootCauseMesg) != -1);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -90,7 +89,7 @@ public class NestedExceptionTests extends TestCase {
 | 
			
		|||
		Exception rootCause = new Exception(rootCauseMesg);
 | 
			
		||||
		// Making a class abstract doesn't _really_ prevent instantiation :-)
 | 
			
		||||
		NestedCheckedException nex = new NestedCheckedException(myMessage, rootCause) {};
 | 
			
		||||
		Assert.assertEquals(nex.getCause(), rootCause);
 | 
			
		||||
		assertEquals(nex.getCause(), rootCause);
 | 
			
		||||
		assertTrue(nex.getMessage().indexOf(myMessage) != -1);
 | 
			
		||||
		assertTrue(nex.getMessage().indexOf(rootCauseMesg) != -1);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -401,7 +401,7 @@ public class DefaultConversionTests {
 | 
			
		|||
	public void convertArrayToObjectAssignableTargetType() {
 | 
			
		||||
		Long[] array = new Long[] { 3L };
 | 
			
		||||
		Long[] result = (Long[]) conversionService.convert(array, Object.class);
 | 
			
		||||
		assertEquals(array, result);
 | 
			
		||||
		assertArrayEquals(array, result);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Test
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -35,8 +35,6 @@ import java.util.UUID;
 | 
			
		|||
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
 | 
			
		||||
import org.springframework.build.junit.Assume;
 | 
			
		||||
import org.springframework.build.junit.TestGroup;
 | 
			
		||||
import org.springframework.core.convert.ConversionFailedException;
 | 
			
		||||
import org.springframework.core.convert.ConverterNotFoundException;
 | 
			
		||||
import org.springframework.core.convert.TypeDescriptor;
 | 
			
		||||
| 
						 | 
				
			
			@ -46,6 +44,8 @@ import org.springframework.core.convert.converter.ConverterFactory;
 | 
			
		|||
import org.springframework.core.convert.converter.GenericConverter;
 | 
			
		||||
import org.springframework.core.io.DescriptiveResource;
 | 
			
		||||
import org.springframework.core.io.Resource;
 | 
			
		||||
import org.springframework.tests.Assume;
 | 
			
		||||
import org.springframework.tests.TestGroup;
 | 
			
		||||
import org.springframework.util.StopWatch;
 | 
			
		||||
import org.springframework.util.StringUtils;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,6 +29,7 @@ import junit.framework.TestCase;
 | 
			
		|||
 * @author Juergen Hoeller
 | 
			
		||||
 * @author Sam Brannen
 | 
			
		||||
 */
 | 
			
		||||
@Deprecated
 | 
			
		||||
public class LabeledEnumTests extends TestCase {
 | 
			
		||||
 | 
			
		||||
	private byte[] serializeObject(final Object obj) throws IOException {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
Some files were not shown because too many files have changed in this diff Show More
		Loading…
	
		Reference in New Issue