Permalink
Browse files

Fix [deprecation] compiler warnings

Fix deprecation compiler warnings by refactoring code or applying
@SuppressWarnings("deprecation") annotations. JUnit tests of
internally deprecated classes are now themselves marked as
@Deprecated.

Numerous EasyMock deprecation warnings will remain until the
migration to mockito can be completed.
  • Loading branch information...
1 parent 9364043 commit 6626a38730050c83a0dd6cdc1bfc510024e9ca95 @philwebb philwebb committed Dec 31, 2012
Showing with 1,665 additions and 1,188 deletions.
  1. +10 −4 spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java
  2. +10 −7 spring-aop/src/test/java/org/springframework/aop/framework/PrototypeTargetTests.java
  3. +6 −3 spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java
  4. +6 −3 spring-aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java
  5. +8 −5 ...op/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java
  6. +8 −4 spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java
  7. +11 −5 spring-aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java
  8. +4 −2 spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java
  9. +5 −2 spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java
  10. +8 −4 spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java
  11. +14 −12 ...test/java/org/springframework/mock/staticmock/AnnotationDrivenStaticEntityMockingControlTest.java
  12. +5 −5 spring-aspects/src/test/java/org/springframework/mock/staticmock/Delegate.java
  13. +2 −0 spring-beans/src/main/java/org/springframework/beans/factory/config/CustomEditorConfigurer.java
  14. +1 −0 spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java
  15. +2 −2 spring-beans/src/main/java/org/springframework/beans/factory/xml/ResourceEntityResolver.java
  16. +10 −8 spring-beans/src/test/java/com/foo/ComponentBeanDefinitionParserTest.java
  17. +18 −9 spring-beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java
  18. +6 −3 spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java
  19. +69 −31 spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java
  20. +5 −3 spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanLookupTests.java
  21. +11 −5 spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanTests.java
  22. +16 −7 .../java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java
  23. +7 −2 ...est/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java
  24. +2 −1 spring-beans/src/test/java/org/springframework/beans/factory/config/CommonsLogFactoryBeanTests.java
  25. +21 −7 spring-beans/src/test/java/org/springframework/beans/factory/config/CustomEditorConfigurerTests.java
  26. +1 −0 spring-beans/src/test/java/org/springframework/beans/factory/config/DeprecatedBeanWarnerTests.java
  27. +14 −9 ...src/test/java/org/springframework/beans/factory/config/ObjectFactoryCreatingFactoryBeanTests.java
  28. +14 −6 ...ng-beans/src/test/java/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests.java
  29. +7 −3 ...beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java
  30. +5 −2 spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionBuilderTests.java
  31. +5 −3 spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionTests.java
  32. +46 −22 spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java
  33. +9 −8 ...eans/src/test/java/org/springframework/beans/factory/support/security/CallbacksSecurityTests.java
  34. +2 −3 spring-beans/src/test/java/org/springframework/beans/factory/xml/AbstractBeanFactoryTests.java
  35. +10 −12 ...g-beans/src/test/java/org/springframework/beans/factory/xml/AbstractListableBeanFactoryTests.java
  36. +34 −27 spring-beans/src/test/java/org/springframework/beans/factory/xml/AutowireWithExclusionTests.java
  37. +4 −3 spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectingReaderEventListener.java
  38. +11 −6 ...g-beans/src/test/java/org/springframework/beans/factory/xml/CollectionsWithDefaultTypesTests.java
  39. +8 −3 spring-beans/src/test/java/org/springframework/beans/factory/xml/DefaultLifecycleMethodsTests.java
  40. +5 −2 spring-beans/src/test/java/org/springframework/beans/factory/xml/MetadataAttachmentTests.java
  41. +1 −1 spring-beans/src/test/java/org/springframework/beans/factory/xml/ProfileXmlBeanDefinitionTests.java
  42. +17 −13 ...s/src/test/java/org/springframework/beans/factory/xml/SimpleConstructorNamespaceHandlerTests.java
  43. +18 −11 ...eans/src/test/java/org/springframework/beans/factory/xml/SimplePropertyNamespaceHandlerTests.java
  44. +14 −7 spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanCollectionTests.java
  45. +66 −64 spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlListableBeanFactoryTests.java
  46. +5 −3 spring-context-support/src/test/java/org/springframework/mail/javamail/JavaMailSenderTests.java
  47. +2 −3 spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java
  48. +1 −1 ...g-context-support/src/test/java/org/springframework/ui/jasperreports/JasperReportsUtilsTests.java
  49. +1 −0 spring-context/src/main/java/org/springframework/context/weaving/DefaultContextLoadTimeWeaver.java
  50. +1 −0 spring-context/src/main/java/org/springframework/scripting/config/ScriptBeanDefinitionParser.java
  51. +1 −0 spring-context/src/main/java/org/springframework/scripting/jruby/JRubyScriptUtils.java
  52. +54 −27 spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java
  53. +2 −1 spring-context/src/test/java/org/springframework/aop/framework/autoproxy/AutoProxyCreatorTests.java
  54. +13 −7 spring-context/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java
  55. +10 −4 spring-context/src/test/java/org/springframework/aop/target/CommonsPoolTargetSourceTests.java
  56. +2 −3 spring-context/src/test/java/org/springframework/beans/factory/AbstractBeanFactoryTests.java
  57. +10 −12 spring-context/src/test/java/org/springframework/beans/factory/AbstractListableBeanFactoryTests.java
  58. +3 −4 ...ontext/src/test/java/org/springframework/beans/factory/parsing/CollectingReaderEventListener.java
  59. +154 −78 spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java
  60. +3 −3 spring-context/src/test/java/org/springframework/cache/config/AnnotationNamespaceDrivenTests.java
  61. +2 −3 spring-context/src/test/java/org/springframework/cache/config/EnableCachingTests.java
  62. +9 −5 ...ext/src/test/java/org/springframework/context/access/ContextSingletonBeanFactoryLocatorTests.java
  63. +16 −5 .../src/test/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessorTests.java
  64. +5 −2 ...c/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests.java
  65. +8 −5 ...rg/springframework/context/annotation/configuration/ConfigurationClassAspectIntegrationTests.java
  66. +1 −1 spring-context/src/test/java/org/springframework/context/event/EventPublicationInterceptorTests.java
  67. +2 −2 ...t/src/test/java/org/springframework/context/support/StaticApplicationContextMulticasterTests.java
  68. +2 −2 spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextTests.java
  69. +2 −2 spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java
  70. +4 −1 ...ng-context/src/test/java/org/springframework/format/support/FormattingConversionServiceTests.java
  71. +9 −5 spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterTests.java
  72. +2 −1 .../src/test/java/org/springframework/scheduling/backportconcurrent/ConcurrentTaskExecutorTests.java
  73. +1 −0 spring-context/src/test/java/org/springframework/scheduling/timer/TimerSupportTests.java
  74. +1 −0 spring-context/src/test/java/org/springframework/scheduling/timer/TimerTaskExecutorTests.java
  75. +16 −17 spring-context/src/test/java/org/springframework/scripting/jruby/JRubyScriptFactoryTests.java
  76. +1 −1 ...-context/src/test/java/org/springframework/scripting/support/ScriptFactoryPostProcessorTests.java
  77. +2 −3 spring-context/src/test/java/org/springframework/validation/DataBinderFieldAccessTests.java
  78. +5 −0 spring-core/src/test/java/org/springframework/core/CollectionFactoryTests.java
  79. +2 −4 spring-core/src/test/java/org/springframework/core/GenericCollectionTypeResolverTests.java
  80. +2 −3 spring-core/src/test/java/org/springframework/core/NestedExceptionTests.java
  81. +1 −1 spring-core/src/test/java/org/springframework/core/convert/support/DefaultConversionTests.java
  82. +1 −0 spring-core/src/test/java/org/springframework/core/enums/LabeledEnumTests.java
  83. +4 −1 spring-core/src/test/java/org/springframework/core/io/support/ResourceArrayPropertyEditorTests.java
  84. +4 −3 spring-core/src/test/java/org/springframework/core/style/ToStringCreatorTests.java
  85. +2 −3 spring-core/src/test/java/org/springframework/util/AutoPopulatingListTests.java
  86. +1 −0 spring-core/src/test/java/org/springframework/util/CachingMapDecoratorTests.java
  87. +40 −38 spring-core/src/test/java/org/springframework/util/ClassUtilsTests.java
  88. +7 −3 spring-core/src/test/java/org/springframework/util/xml/StaxSourceTests.java
  89. +32 −31 spring-expression/src/test/java/org/springframework/expression/spel/DefaultComparatorUnitTests.java
  90. +24 −23 ...expression/src/test/java/org/springframework/expression/spel/ExpressionLanguageScenarioTests.java
  91. +61 −58 spring-expression/src/test/java/org/springframework/expression/spel/ExpressionStateTests.java
  92. +44 −43 spring-expression/src/test/java/org/springframework/expression/spel/ExpressionTestCase.java
  93. +3 −3 .../src/test/java/org/springframework/expression/spel/ExpressionTestsUsingCoreConversionService.java
  94. +6 −6 spring-expression/src/test/java/org/springframework/expression/spel/InProgressTests.java
  95. +23 −21 spring-expression/src/test/java/org/springframework/expression/spel/LiteralExpressionTests.java
  96. +5 −4 spring-expression/src/test/java/org/springframework/expression/spel/LiteralTests.java
  97. +5 −5 spring-expression/src/test/java/org/springframework/expression/spel/MapAccessTests.java
  98. +4 −4 spring-expression/src/test/java/org/springframework/expression/spel/OperatorOverloaderTests.java
  99. +18 −17 spring-expression/src/test/java/org/springframework/expression/spel/OperatorTests.java
  100. +5 −4 spring-expression/src/test/java/org/springframework/expression/spel/ParsingTests.java
  101. +10 −9 spring-expression/src/test/java/org/springframework/expression/spel/PerformanceTests.java
  102. +20 −18 spring-expression/src/test/java/org/springframework/expression/spel/PropertyAccessTests.java
  103. +14 −12 spring-expression/src/test/java/org/springframework/expression/spel/ScenariosForSpringSecurity.java
  104. +26 −22 spring-expression/src/test/java/org/springframework/expression/spel/SetValueTests.java
  105. +57 −54 spring-expression/src/test/java/org/springframework/expression/spel/SpelDocumentationTests.java
  106. +14 −12 spring-expression/src/test/java/org/springframework/expression/spel/StandardTypeLocatorTests.java
  107. +60 −57 ...-expression/src/test/java/org/springframework/expression/spel/TemplateExpressionParsingTests.java
  108. +3 −3 spring-expression/src/test/java/org/springframework/expression/spel/VariableAndFunctionTests.java
  109. +91 −86 ...g-expression/src/test/java/org/springframework/expression/spel/support/ReflectionHelperTests.java
  110. +9 −7 spring-jdbc/src/test/java/org/springframework/jdbc/config/JdbcNamespaceIntegrationTests.java
  111. +0 −1 spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateTests.java
  112. +1 −0 spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcTemplateTests.java
  113. +5 −2 spring-jdbc/src/test/java/org/springframework/jdbc/object/GenericSqlQueryTests.java
  114. +4 −3 spring-jdbc/src/test/java/org/springframework/jdbc/object/GenericStoredProcedureTests.java
  115. +6 −3 spring-orm/src/test/java/org/springframework/orm/hibernate3/LocalSessionFactoryBeanTests.java
  116. +13 −7 spring-oxm/src/test/java/org/springframework/oxm/castor/CastorMarshallerTests.java
  117. +17 −9 spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java
  118. +1 −0 spring-struts/src/test/java/org/springframework/web/servlet/view/tiles/TestComponentController.java
  119. +1 −0 spring-struts/src/test/java/org/springframework/web/servlet/view/tiles/TilesViewTests.java
  120. +1 −1 spring-test/src/main/java/org/springframework/test/AssertThrows.java
  121. +4 −3 spring-tx/src/test/java/org/springframework/beans/factory/parsing/CollectingReaderEventListener.java
  122. +9 −5 spring-tx/src/test/java/org/springframework/transaction/interceptor/BeanFactoryTransactionTests.java
  123. +1 −0 spring-web/src/main/java/org/springframework/web/util/UrlPathHelper.java
  124. +1 −0 spring-web/src/test/java/org/springframework/http/client/CommonsHttpRequestFactoryTests.java
  125. +11 −8 spring-web/src/test/java/org/springframework/http/converter/xml/SourceHttpMessageConverterTests.java
  126. +1 −0 spring-web/src/test/java/org/springframework/mock/web/test/MockExpressionEvaluator.java
  127. +3 −1 spring-web/src/test/java/org/springframework/mock/web/test/MockPageContext.java
  128. +1 −0 spring-web/src/test/java/org/springframework/remoting/jaxrpc/JaxRpcSupportTests.java
  129. +1 −0 spring-web/src/test/java/org/springframework/web/jsf/DelegatingVariableResolverTests.java
  130. +7 −4 ...ng-web/src/test/java/org/springframework/web/multipart/commons/CommonsMultipartResolverTests.java
  131. +1 −0 spring-web/src/test/java/org/springframework/web/util/ExpressionEvaluationUtilsTests.java
  132. +3 −0 spring-web/src/test/java/org/springframework/web/util/UriUtilsTests.java
  133. +2 −3 spring-webmvc-portlet/src/test/java/org/springframework/beans/factory/AbstractBeanFactoryTests.java
  134. +10 −12 ...mvc-portlet/src/test/java/org/springframework/beans/factory/AbstractListableBeanFactoryTests.java
  135. +2 −2 ...mvc-portlet/src/test/java/org/springframework/web/portlet/bind/PortletRequestDataBinderTests.java
  136. +1 −0 spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/mvc/CommandControllerTests.java
  137. +1 −2 spring-webmvc/src/test/java/org/springframework/web/context/AbstractBeanFactoryTests.java
  138. +8 −10 spring-webmvc/src/test/java/org/springframework/web/context/AbstractListableBeanFactoryTests.java
  139. +18 −6 spring-webmvc/src/test/java/org/springframework/web/context/support/ServletContextSupportTests.java
  140. +2 −3 spring-webmvc/src/test/java/org/springframework/web/servlet/DispatcherServletTests.java
  141. +1 −0 spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/FormControllerTests.java
  142. +1 −0 spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/WizardFormControllerTests.java
  143. +1 −0 ...org/springframework/web/servlet/mvc/annotation/AnnotationMethodHandlerExceptionResolverTests.java
  144. +1 −0 ...ava/org/springframework/web/servlet/mvc/annotation/RequestSpecificMappingInfoComparatorTests.java
  145. +7 −3 ...rc/test/java/org/springframework/web/servlet/mvc/annotation/ServletAnnotationControllerTests.java
  146. +4 −1 .../test/java/org/springframework/web/servlet/mvc/annotation/ServletAnnotationMappingUtilsTests.java
  147. +1 −0 spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/annotation/Spr7766Tests.java
  148. +1 −0 spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/annotation/Spr7839Tests.java
  149. +3 −1 ...a/org/springframework/web/servlet/mvc/annotation/UriTemplateServletAnnotationControllerTests.java
  150. +2 −1 spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/mapping/BuyForm.java
  151. +1 −1 ...java/org/springframework/web/servlet/mvc/method/annotation/AbstractServletHandlerMethodTests.java
  152. +1 −1 spring-webmvc/src/test/java/org/springframework/web/servlet/view/velocity/VelocityRenderTests.java
  153. +1 −0 spring-webmvc/src/test/java/org/springframework/web/servlet/view/xslt/TestXsltViewTests.java
View
14 ...p/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java
@@ -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 @@
@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 void testDuplicatePointcutConfig() {
@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) {
View
17 spring-aop/src/test/java/org/springframework/aop/framework/PrototypeTargetTests.java
@@ -22,7 +22,8 @@
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,25 +38,27 @@
@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);
}
@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);
}
View
9 ...p/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java
@@ -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 @@
@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);
View
9 spring-aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java
@@ -20,7 +20,8 @@
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,15 +37,17 @@
@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());
}
@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());
View
13 ...est/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java
@@ -21,8 +21,8 @@
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 @@
@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 void testSinglePattern() throws Throwable {
@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 void testMultiplePatterns() throws Throwable {
@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
View
12 spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java
@@ -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.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 @@
/** 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);
}
/**
View
16 spring-aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java
@@ -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 @@
@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 void testLazyInitSingletonTargetSource() {
@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 void testCustomLazyInitSingletonTargetSource() {
@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");
View
6 spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java
@@ -41,10 +41,12 @@
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();
View
7 spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java
@@ -22,7 +22,9 @@
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 @@
@Before
public void setUp() throws Exception {
- this.beanFactory = new XmlBeanFactory(CONTEXT);
+ this.beanFactory = new DefaultListableBeanFactory();
+ new XmlBeanDefinitionReader((BeanDefinitionRegistry) this.beanFactory).loadBeanDefinitions(CONTEXT);
}
/**
View
12 spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java
@@ -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 @@
/** 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);
}
/**
View
26 ...a/org/springframework/mock/staticmock/AnnotationDrivenStaticEntityMockingControlTest.java
@@ -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 void testNoArgIntReturn() {
Person.countPeople();
expectReturn(expectedCount);
playback();
- Assert.assertEquals(expectedCount, Person.countPeople());
+ assertEquals(expectedCount, Person.countPeople());
}
@Test(expected=PersistenceException.class)
@@ -61,7 +63,7 @@ public void testArgMethodMatches() {
Person.findPerson(id);
expectReturn(found);
playback();
- Assert.assertEquals(found, Person.findPerson(id));
+ assertEquals(found, Person.findPerson(id));
}
@@ -81,10 +83,10 @@ public void testLongSeriesOfCalls() {
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 void testLongSeriesOfCalls() {
public void testArgMethodNoMatchExpectReturn() {
try {
new Delegate().testArgMethodNoMatchExpectReturn();
- Assert.fail();
+ fail();
} catch (IllegalArgumentException expected) {
}
}
@@ -105,7 +107,7 @@ public void testArgMethodNoMatchExpectThrow() {
}
private void called(Person found, long id) {
- Assert.assertEquals(found, Person.findPerson(id));
+ assertEquals(found, Person.findPerson(id));
}
@Test
View
10 spring-aspects/src/test/java/org/springframework/mock/staticmock/Delegate.java
@@ -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 void testArgMethodNoMatchExpectReturn() {
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 void testArgMethodNoMatchExpectThrow() {
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 void failTooFewCalls() {
Person.countPeople();
AnnotationDrivenStaticEntityMockingControl.expectReturn(25);
AnnotationDrivenStaticEntityMockingControl.playback();
- Assert.assertEquals(found, Person.findPerson(id));
+ assertEquals(found, Person.findPerson(id));
}
@Test
View
2 ...-beans/src/main/java/org/springframework/beans/factory/config/CustomEditorConfigurer.java
@@ -234,6 +234,8 @@ public SharedPropertyEditorRegistrar(Class requiredType, PropertyEditor sharedEd
this.sharedEditor = sharedEditor;
}
+ @Override
+ @SuppressWarnings("deprecation")
public void registerCustomEditors(PropertyEditorRegistry registry) {
if (!(registry instanceof PropertyEditorRegistrySupport)) {
throw new IllegalArgumentException("Cannot registered shared editor " +
View
1 ...ans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java
@@ -716,6 +716,7 @@ public void parseMetaElements(Element ele, BeanMetadataAttributeAccessor attribu
}
}
+ @SuppressWarnings("deprecation")
public int getAutowireMode(String attValue) {
String att = attValue;
if (DEFAULT_VALUE.equals(att)) {
View
4 spring-beans/src/main/java/org/springframework/beans/factory/xml/ResourceEntityResolver.java
@@ -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 InputSource resolveEntity(String publicId, String systemId) throws SAXExc
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());
View
18 spring-beans/src/test/java/com/foo/ComponentBeanDefinitionParserTest.java
@@ -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 void testBionicSecondLevenChildren() throws Exception {
assertThat("Karate-1", equalTo(components.get(0).getName()));
assertThat("Sport-1", equalTo(components.get(1).getName()));
}
-}
+}
View
27 spring-beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java
@@ -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.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 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;
}
View
9 spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java
@@ -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.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 @@
@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) {
View
100 ...eans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java
@@ -549,7 +549,9 @@ public void testSelfReference() {
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 void testPossibleMatches() {
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 void registerCustomEditors(PropertyEditorRegistry registry) {
});
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 Float convert(String source) {
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 void registerCustomEditors(PropertyEditorRegistry registry) {
});
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 void testRegisterExistingSingletonWithAutowire() {
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 void testArrayPropertyWithAutowiring() throws MalformedURLException {
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 void testArrayPropertyWithAutowiring() throws MalformedURLException {
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 void testArrayConstructorWithAutowiring() {
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 void testArrayConstructorWithAutowiring() {
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 void testDoubleArrayConstructorWithAutowiring() throws MalformedURLExcept
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 void testDoubleArrayConstructorWithOptionalAutowiring() throws MalformedU
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 void testAutowireWithNoDependencies() {
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 void testAutowireWithSatisfiedJavaBeanDependency() {
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 void testAutowireWithSatisfiedConstructorDependency() {
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 void testAutowireWithTwoMatchesForConstructorDependency() {
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 void testAutowireWithUnsatisfiedConstructorDependency() {
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 void testApplyBeanPropertyValues() {
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 void testApplyBeanPropertyValuesWithIncompleteDefinition() {
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 void testConfigureBean() {
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 void testConfigureBeanWithAutowiring() {
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 void testExtensiveCircularReference() {
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 void testExtensiveCircularReference() {
@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 void testCircularReferenceThroughAutowiring() {
@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 void testCircularReferenceThroughFactoryBeanAutowiring() {
@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 void testCircularReferenceThroughFactoryBeanTypeCheck() {
@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();
}
View
8 spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanLookupTests.java
@@ -22,9 +22,10 @@
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 @@
@Before
public void setUp() {
- beanFactory = new XmlBeanFactory(
+ beanFactory = new DefaultListableBeanFactory();
+ new XmlBeanDefinitionReader((BeanDefinitionRegistry) beanFactory).loadBeanDefinitions(
new ClassPathResource("FactoryBeanLookupTests-context.xml", this.getClass()));
}
View
16 spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanTests.java
@@ -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 @@
@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 void testFactoryBeansWithAutowiring() throws Exception {
@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);
View
23 ...g/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java
@@ -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,23 +33,22 @@
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;
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 void testObjectFactoryInjectionIntoPrototypeBean() {
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");
View
9 .../org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java
@@ -32,6 +32,7 @@
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 void testObjectFactoryFieldInjectionIntoPrototypeBean() {
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 void testObjectFactoryMethodInjectionIntoPrototypeBean() {
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);
View
3 ...ns/src/test/java/org/springframework/beans/factory/config/CommonsLogFactoryBeanTests.java
@@ -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 @@
* @author Rick Evans
* @author Chris Beams
*/
+@SuppressWarnings("deprecation")
public final class CommonsLogFactoryBeanTests {
@Test
View
28 ...s/src/test/java/org/springframework/beans/factory/config/CustomEditorConfigurerTests.java
@@ -62,10 +62,14 @@ public void registerCustomEditors(PropertyEditorRegistry registry) {
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 void testCustomEditorConfigurerWithEditorInstance() throws ParseException
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 void testCustomEditorConfigurerWithEditorClassName() throws ParseExceptio
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 void testCustomEditorConfigurerWithEditorAsClass() throws ParseException
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 void testCustomEditorConfigurerWithRequiredTypeArray() throws ParseExcept
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);
View
1 ...ans/src/test/java/org/springframework/beans/factory/config/DeprecatedBeanWarnerTests.java
@@ -38,6 +38,7 @@
@Test
+ @SuppressWarnings("deprecation")
public void postProcess() {
beanFactory = new DefaultListableBeanFactory();
BeanDefinition def = new RootBeanDefinition(MyDeprecatedBean.class);
View
23 .../java/org/springframework/beans/factory/config/ObjectFactoryCreatingFactoryBeanTests.java
@@ -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 @@
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");
}
View
20 .../src/test/java/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests.java
@@ -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 @@
@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 void testPropertyPathFactoryBeanWithSingletonResult() {
@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 void testPropertyPathFactoryBeanWithPrototypeResult() {
@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());
View
10 ...c/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java
@@ -371,7 +371,8 @@ private void doTestPropertyPlaceholderConfigurer(boolean parentChildSeparation)
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 @@ private void doTestPropertyPlaceholderConfigurer(boolean parentChildSeparation)
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 @@ private void doTestPropertyPlaceholderConfigurer(boolean parentChildSeparation)
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);
View
7 ...s/src/test/java/org/springframework/beans/factory/support/BeanDefinitionBuilderTests.java
@@ -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 junit.framework.TestCase;
+import org.springframework.beans.factory.config.BeanDefinition;
+
import test.beans.TestBean;
/**
@@ -31,7 +33,8 @@
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]);
}
View
8 ...ng-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionTests.java
@@ -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 @@
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 void testBeanDefinitionMerging() {
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);
View
68 ...ans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java
@@ -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.Map;
import java.util.Set;
-import static org.junit.Assert.*;
-
import org.junit.Test;
import org.mockito.Mockito;
-
-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.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;
+
/**
* @author Juergen Hoeller
* @author Chris Beams
@@ -94,7 +98,8 @@ public void testGenericListPropertyWithAutowiring() throws MalformedURLException
bf.registerSingleton("resource1", new UrlResource("http://localhost:8080"));