Java Doc for AbstractDependencyInjectionSpringContextTests.java in  » J2EE » spring-framework-2.0.6 » org » springframework » test » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » spring framework 2.0.6 » org.springframework.test 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.springframework.test.ConditionalTestCase
   org.springframework.test.AbstractSpringContextTests
      org.springframework.test.AbstractSingleSpringContextTests
         org.springframework.test.AbstractDependencyInjectionSpringContextTests

All known Subclasses:   org.springframework.test.AbstractTransactionalSpringContextTests,
AbstractDependencyInjectionSpringContextTests
abstract public class AbstractDependencyInjectionSpringContextTests extends AbstractSingleSpringContextTests (Code)
Convenient superclass for tests depending on a Spring context. The test instance itself is populated by Dependency Injection.

Really for integration testing, not unit testing. You should not normally use the Spring container for unit tests: simply populate your POJOs in plain JUnit tests!

This supports two modes of populating the test:

  • Via Setter Dependency Injection. Simply express dependencies on objects in the test fixture, and they will be satisfied by autowiring by type.
  • Via Field Injection. Declare protected variables of the required type which match named beans in the context. This is autowire by name, rather than type. This approach is based on an approach originated by Ara Abrahmian. Setter Dependency Injection is the default: set the "populateProtectedVariables" property to true in the constructor to switch on Field Injection.

author:
   Rod Johnson
author:
   Rob Harrop
author:
   Rick Evans
since:
   1.1.1
See Also:   AbstractDependencyInjectionSpringContextTests.setDirty
See Also:   AbstractDependencyInjectionSpringContextTests.contextKey
See Also:   AbstractDependencyInjectionSpringContextTests.getContext
See Also:   AbstractDependencyInjectionSpringContextTests.getConfigLocations


Field Summary
final public static  intAUTOWIRE_BY_NAME
     Constant that indicates autowiring bean properties by name.
final public static  intAUTOWIRE_BY_TYPE
     Constant that indicates autowiring bean properties by type.
final public static  intAUTOWIRE_NO
     Constant that indicates no autowiring at all.

Constructor Summary
public  AbstractDependencyInjectionSpringContextTests()
     Default constructor for AbstractDependencyInjectionSpringContextTests.
public  AbstractDependencyInjectionSpringContextTests(String name)
     Constructor for AbstractDependencyInjectionSpringContextTests with a JUnit name.

Method Summary
final public  intgetAutowireMode()
     Return the autowire mode for test properties set by Dependency Injection.
protected  voidinjectDependencies()
     Inject dependencies into 'this' instance (that is, this test instance).
final public  booleanisDependencyCheck()
     Return whether or not dependency checking should be performed for test properties set by Dependency Injection.
final public  booleanisPopulateProtectedVariables()
     Return whether to populate protected variables of this test case.
protected  voidprepareTestInstance()
     Prepare this test instance, injecting dependencies into its protected fields and its bean properties.
final public  voidsetAutowireMode(int autowireMode)
     Set the autowire mode for test properties set by Dependency Injection.

The default is "AUTOWIRE_BY_TYPE".

final public  voidsetDependencyCheck(boolean dependencyCheck)
     Set whether or not dependency checking should be performed for test properties set by Dependency Injection.
final public  voidsetPopulateProtectedVariables(boolean populateFields)
     Set whether to populate protected variables of this test case.

Field Detail
AUTOWIRE_BY_NAME
final public static int AUTOWIRE_BY_NAME(Code)
Constant that indicates autowiring bean properties by name.
See Also:   AbstractDependencyInjectionSpringContextTests.setAutowireMode



AUTOWIRE_BY_TYPE
final public static int AUTOWIRE_BY_TYPE(Code)
Constant that indicates autowiring bean properties by type.
See Also:   AbstractDependencyInjectionSpringContextTests.setAutowireMode



AUTOWIRE_NO
final public static int AUTOWIRE_NO(Code)
Constant that indicates no autowiring at all.
See Also:   AbstractDependencyInjectionSpringContextTests.setAutowireMode




Constructor Detail
AbstractDependencyInjectionSpringContextTests
public AbstractDependencyInjectionSpringContextTests()(Code)
Default constructor for AbstractDependencyInjectionSpringContextTests.



AbstractDependencyInjectionSpringContextTests
public AbstractDependencyInjectionSpringContextTests(String name)(Code)
Constructor for AbstractDependencyInjectionSpringContextTests with a JUnit name.
Parameters:
  name - the name of this text fixture




Method Detail
getAutowireMode
final public int getAutowireMode()(Code)
Return the autowire mode for test properties set by Dependency Injection.



injectDependencies
protected void injectDependencies() throws Exception(Code)
Inject dependencies into 'this' instance (that is, this test instance).

The default implementation populates protected variables if the AbstractDependencyInjectionSpringContextTests.populateProtectedVariables() appropriate flag is set , else uses autowiring if autowiring is switched on (which it is by default).

Override this method if you need full control over how dependencies are injected into the test instance.
throws:
  Exception - in case of dependency injection failure
See Also:   AbstractDependencyInjectionSpringContextTests.populateProtectedVariables()
See Also:   




isDependencyCheck
final public boolean isDependencyCheck()(Code)
Return whether or not dependency checking should be performed for test properties set by Dependency Injection.



isPopulateProtectedVariables
final public boolean isPopulateProtectedVariables()(Code)
Return whether to populate protected variables of this test case.



prepareTestInstance
protected void prepareTestInstance() throws Exception(Code)
Prepare this test instance, injecting dependencies into its protected fields and its bean properties.



setAutowireMode
final public void setAutowireMode(int autowireMode)(Code)
Set the autowire mode for test properties set by Dependency Injection.

The default is "AUTOWIRE_BY_TYPE". Can be set to "AUTOWIRE_BY_NAME" or "AUTOWIRE_NO" instead.
See Also:   AbstractDependencyInjectionSpringContextTests.AUTOWIRE_BY_TYPE
See Also:   AbstractDependencyInjectionSpringContextTests.AUTOWIRE_BY_NAME
See Also:   AbstractDependencyInjectionSpringContextTests.AUTOWIRE_NO




setDependencyCheck
final public void setDependencyCheck(boolean dependencyCheck)(Code)
Set whether or not dependency checking should be performed for test properties set by Dependency Injection.

The default is "true", meaning that tests cannot be run unless all properties are populated.




setPopulateProtectedVariables
final public void setPopulateProtectedVariables(boolean populateFields)(Code)
Set whether to populate protected variables of this test case. Default is "false".



Fields inherited from org.springframework.test.AbstractSingleSpringContextTests
protected ConfigurableApplicationContext applicationContext(Code)(Java Doc)

Methods inherited from org.springframework.test.AbstractSingleSpringContextTests
protected Object contextKey()(Code)(Java Doc)
protected ConfigurableApplicationContext createApplicationContext(String[] locations)(Code)(Java Doc)
protected void customizeBeanFactory(DefaultListableBeanFactory beanFactory)(Code)(Java Doc)
final public ConfigurableApplicationContext getApplicationContext()(Code)(Java Doc)
protected String[] getConfigLocations()(Code)(Java Doc)
protected String getConfigPath()(Code)(Java Doc)
protected String[] getConfigPaths()(Code)(Java Doc)
final public int getLoadCount()(Code)(Java Doc)
protected ConfigurableApplicationContext loadContext(Object key) throws Exception(Code)(Java Doc)
protected ConfigurableApplicationContext loadContextLocations(String[] locations) throws Exception(Code)(Java Doc)
protected void onSetUp() throws Exception(Code)(Java Doc)
protected void onTearDown() throws Exception(Code)(Java Doc)
protected void prepareTestInstance() throws Exception(Code)(Java Doc)
protected void setDirty()(Code)(Java Doc)
final protected void setUp() throws Exception(Code)(Java Doc)
final protected void tearDown() throws Exception(Code)(Java Doc)

Methods inherited from org.springframework.test.AbstractSpringContextTests
final public void addContext(Object key, ConfigurableApplicationContext context)(Code)(Java Doc)
protected String contextKeyString(Object contextKey)(Code)(Java Doc)
final protected ConfigurableApplicationContext getContext(Object key) throws Exception(Code)(Java Doc)
final protected boolean hasCachedContext(Object contextKey)(Code)(Java Doc)
abstract protected ConfigurableApplicationContext loadContext(Object key) throws Exception(Code)(Java Doc)
final protected void setDirty(Object contextKey)(Code)(Java Doc)

Fields inherited from org.springframework.test.ConditionalTestCase
final protected Log logger(Code)(Java Doc)

Methods inherited from org.springframework.test.ConditionalTestCase
public static int getDisabledTestCount()(Code)(Java Doc)
protected boolean isDisabledInThisEnvironment(String testMethodName)(Code)(Java Doc)
protected int recordDisabled()(Code)(Java Doc)
public void runBare() throws Throwable(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.