Java Doc for AbstractSingleSpringContextTests.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

All known Subclasses:   org.springframework.test.AbstractDependencyInjectionSpringContextTests,
AbstractSingleSpringContextTests
abstract public class AbstractSingleSpringContextTests extends AbstractSpringContextTests (Code)
Abstract JUnit test class that holds and exposes a single Spring org.springframework.context.ApplicationContext ApplicationContext .

This class will cache contexts based on a context key: normally the config locations String array describing the Spring resource descriptors making up the context. Unless the AbstractSingleSpringContextTests.setDirty() method is called by a test, the context will not be reloaded, even across different subclasses of this test. This is particularly beneficial if your context is slow to construct, for example if you are using Hibernate and the time taken to load the mappings is an issue.

For such standard usage, simply override the AbstractSingleSpringContextTests.getConfigLocations() method and provide the desired config files.

If you don't want to load a standard context from an array of config locations, you can override the AbstractSingleSpringContextTests.contextKey() method. In conjunction with this you typically need to override the AbstractSingleSpringContextTests.loadContext(Object) method, which by default loads the locations specified in the AbstractSingleSpringContextTests.getConfigLocations() method.

WARNING: When doing integration tests from within Eclipse, only use classpath resource URLs. Else, you may see misleading failures when changing context locations.
author:
   Juergen Hoeller
author:
   Rod Johnson
since:
   2.0
See Also:   AbstractSingleSpringContextTests.getConfigLocations()
See Also:   AbstractSingleSpringContextTests.contextKey()
See Also:   AbstractSingleSpringContextTests.loadContext(Object)
See Also:   AbstractSingleSpringContextTests.getApplicationContext()



Field Summary
protected  ConfigurableApplicationContextapplicationContext
    

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

Method Summary
protected  ObjectcontextKey()
     Return a key for this context.
protected  ConfigurableApplicationContextcreateApplicationContext(String[] locations)
     Create a Spring ApplicationContext for use by this test.

The default implementation creates a standard GenericApplicationContext instance, populates it from the specified config locations through a org.springframework.beans.factory.xml.XmlBeanDefinitionReader , and calls AbstractSingleSpringContextTests.customizeBeanFactory to allow for customizing the context's DefaultListableBeanFactory.
Parameters:
  locations - the config locations (as Spring resource locations,e.g.

protected  voidcustomizeBeanFactory(DefaultListableBeanFactory beanFactory)
     Customize the internal bean factory of the ApplicationContext used by this test.

The default implementation is empty.

final public  ConfigurableApplicationContextgetApplicationContext()
     Return the ApplicationContext that this base class manages.
protected  String[]getConfigLocations()
     Subclasses can override this method to return the locations of their config files, unless they override AbstractSingleSpringContextTests.contextKey() and AbstractSingleSpringContextTests.loadContext(Object) instead.

A plain path will be treated as class path location, e.g.: "org/springframework/whatever/foo.xml".

protected  StringgetConfigPath()
     Subclasses can override this method to return a single path to a config file, relative to the concrete test class.

A plain path, e.g.

protected  String[]getConfigPaths()
     Subclasses can override this method to return paths to their config files, relative to the concrete test class.

A plain path, e.g.

final public  intgetLoadCount()
     Return the current number of context load attempts.
protected  ConfigurableApplicationContextloadContext(Object key)
     This implementation assumes a key of type String array and loads a context from the given locations.
protected  ConfigurableApplicationContextloadContextLocations(String[] locations)
     Load a Spring ApplicationContext from the given config locations.

The default implementation creates a standard AbstractSingleSpringContextTests.createApplicationContext GenericApplicationContext , allowing for customizing the internal bean factory through AbstractSingleSpringContextTests.customizeBeanFactory .
Parameters:
  locations - the config locations (as Spring resource locations,e.g.

protected  voidonSetUp()
     Subclasses can override this method in place of the setUp() method, which is final in this class.
protected  voidonTearDown()
     Subclasses can override this to add custom behavior on teardown.
protected  voidprepareTestInstance()
     Prepare this test instance, for example populating its fields.
protected  voidsetDirty()
     Called to say that the "applicationContext" instance variable is dirty and should be reloaded.
final protected  voidsetUp()
     This implementation is final.
final protected  voidtearDown()
     This implementation is final.

Field Detail
applicationContext
protected ConfigurableApplicationContext applicationContext(Code)
Application context this test will run against




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



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




Method Detail
contextKey
protected Object contextKey()(Code)
Return a key for this context. Default is the config location array as determined by AbstractSingleSpringContextTests.getConfigLocations() .

If you override this method, you will typically have to override AbstractSingleSpringContextTests.loadContext(Object) as well, being able to handle the key type that this method returns. the context key
See Also:   AbstractSingleSpringContextTests.getConfigLocations()




createApplicationContext
protected ConfigurableApplicationContext createApplicationContext(String[] locations)(Code)
Create a Spring ApplicationContext for use by this test.

The default implementation creates a standard GenericApplicationContext instance, populates it from the specified config locations through a org.springframework.beans.factory.xml.XmlBeanDefinitionReader , and calls AbstractSingleSpringContextTests.customizeBeanFactory to allow for customizing the context's DefaultListableBeanFactory.
Parameters:
  locations - the config locations (as Spring resource locations,e.g. full classpath locations or any kind of URL) the GenericApplicationContext instance
See Also:   AbstractSingleSpringContextTests.loadContextLocations
See Also:   AbstractSingleSpringContextTests.customizeBeanFactory




customizeBeanFactory
protected void customizeBeanFactory(DefaultListableBeanFactory beanFactory)(Code)
Customize the internal bean factory of the ApplicationContext used by this test.

The default implementation is empty. Can be overridden in subclasses to customize DefaultListableBeanFactory's standard settings.
Parameters:
  beanFactory - the newly created bean factory for this context
See Also:   AbstractSingleSpringContextTests.loadContextLocations
See Also:   AbstractSingleSpringContextTests.createApplicationContext
See Also:   org.springframework.beans.factory.support.DefaultListableBeanFactory.setAllowBeanDefinitionOverriding
See Also:   org.springframework.beans.factory.support.DefaultListableBeanFactory.setAllowEagerClassLoading
See Also:   org.springframework.beans.factory.support.DefaultListableBeanFactory.setAllowCircularReferences
See Also:   org.springframework.beans.factory.support.DefaultListableBeanFactory.setAllowRawInjectionDespiteWrapping




getApplicationContext
final public ConfigurableApplicationContext getApplicationContext()(Code)
Return the ApplicationContext that this base class manages.



getConfigLocations
protected String[] getConfigLocations()(Code)
Subclasses can override this method to return the locations of their config files, unless they override AbstractSingleSpringContextTests.contextKey() and AbstractSingleSpringContextTests.loadContext(Object) instead.

A plain path will be treated as class path location, e.g.: "org/springframework/whatever/foo.xml". Note however that you may prefix path locations with standard Spring resource prefixes. Therefore, a config location path prefixed with "classpath:" with behave the same as a plain path, but a config location such as "file:/some/path/path/location/appContext.xml" will be treated as a filesystem location.

The default implementation builds config locations for the config paths specified through AbstractSingleSpringContextTests.getConfigPaths() . an array of config locations
See Also:   AbstractSingleSpringContextTests.getConfigPaths()
See Also:   org.springframework.core.io.ResourceLoader.getResource(String)




getConfigPath
protected String getConfigPath()(Code)
Subclasses can override this method to return a single path to a config file, relative to the concrete test class.

A plain path, e.g. "context.xml", will be loaded as classpath resource from the same package that the concrete test class is defined in. A path starting with a slash is treated as fully qualified class path location, e.g.: "/org/springframework/whatever/foo.xml".

The default implementation simply returns null. an array of config locations
See Also:   AbstractSingleSpringContextTests.getConfigPath()
See Also:   java.lang.Class.getResource(String)




getConfigPaths
protected String[] getConfigPaths()(Code)
Subclasses can override this method to return paths to their config files, relative to the concrete test class.

A plain path, e.g. "context.xml", will be loaded as classpath resource from the same package that the concrete test class is defined in. A path starting with a slash is treated as fully qualified class path location, e.g.: "/org/springframework/whatever/foo.xml".

The default implementation builds an array for the config path specified through AbstractSingleSpringContextTests.getConfigPath() . an array of config locations
See Also:   AbstractSingleSpringContextTests.getConfigPath()
See Also:   java.lang.Class.getResource(String)




getLoadCount
final public int getLoadCount()(Code)
Return the current number of context load attempts.



loadContext
protected ConfigurableApplicationContext loadContext(Object key) throws Exception(Code)
This implementation assumes a key of type String array and loads a context from the given locations.

If you override AbstractSingleSpringContextTests.contextKey() , you will typically have to override this method as well, being able to handle the key type that contextKey() returns.
See Also:   AbstractSingleSpringContextTests.getConfigLocations()




loadContextLocations
protected ConfigurableApplicationContext loadContextLocations(String[] locations) throws Exception(Code)
Load a Spring ApplicationContext from the given config locations.

The default implementation creates a standard AbstractSingleSpringContextTests.createApplicationContext GenericApplicationContext , allowing for customizing the internal bean factory through AbstractSingleSpringContextTests.customizeBeanFactory .
Parameters:
  locations - the config locations (as Spring resource locations,e.g. full classpath locations or any kind of URL) the corresponding ApplicationContext instance (potentially cached)
throws:
  Exception - if context loading failed
See Also:   AbstractSingleSpringContextTests.createApplicationContext
See Also:   AbstractSingleSpringContextTests.customizeBeanFactory




onSetUp
protected void onSetUp() throws Exception(Code)
Subclasses can override this method in place of the setUp() method, which is final in this class. This implementation does nothing.
throws:
  Exception - simply let any exception propagate



onTearDown
protected void onTearDown() throws Exception(Code)
Subclasses can override this to add custom behavior on teardown.
throws:
  Exception - simply let any exception propagate



prepareTestInstance
protected void prepareTestInstance() throws Exception(Code)
Prepare this test instance, for example populating its fields. The context has already been loaded at the time of this callback.

The default implementation does nothing.
throws:
  Exception - in case of preparation failure




setDirty
protected void setDirty()(Code)
Called to say that the "applicationContext" instance variable is dirty and should be reloaded. We need to do this if a test has modified the context (for example, by replacing a bean definition).



setUp
final protected void setUp() throws Exception(Code)
This implementation is final. Override onSetUp for custom behavior.
See Also:   AbstractSingleSpringContextTests.onSetUp()



tearDown
final protected void tearDown() throws Exception(Code)
This implementation is final. Override onTearDown for custom behavior.
See Also:   AbstractSingleSpringContextTests.onTearDown()



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.