Java Doc for SpringModule.java in  » Testing » unitils » org » unitils » spring » 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 » Testing » unitils » org.unitils.spring 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.unitils.spring.SpringModule

SpringModule
public class SpringModule implements Module(Code)
A module for Spring enabling a test class by offering an easy way to load application contexts and an easy way of retrieving beans from the context and injecting them in the test.

The application context loading can be achieved by using the SpringApplicationContext annotation. These contexts are cached, so a context will be reused when possible. For example suppose a superclass loads a context and a test-subclass wants to use this context, it will not create a new one. SpringModule.invalidateApplicationContext } can be used to force a reloading of a context if needed.

Spring bean retrieval can be done by annotating the corresponding fields in the test with following annotations: SpringBean , SpringBeanByName and SpringBeanByType .

See the javadoc of these annotations for more info on how you can use them.
author:
   Tim Ducheyne
author:
   Filip Neven


Inner Class :protected class SpringTestListener extends TestListener

Field Summary
final public static  StringPROPKEY_APPLICATION_CONTEXT_FACTORY_CLASS_NAME
    


Method Summary
public  voidassignSpringBeans(Object testObject)
     Gets the spring beans for all fields that are annotated with SpringBean .
public  voidassignSpringBeansByName(Object testObject)
     Gets the spring beans for all fields that are annotated with SpringBeanByName .
public  voidassignSpringBeansByType(Object testObject)
     Gets the spring beans for all fields methods that are annotated with SpringBeanByType .
public  TestListenercreateTestListener()
    
public  ApplicationContextgetApplicationContext(Object testObject)
     Gets the application context for this test.
public  TgetBeanPostProcessor(Object testObject, Class<T> beanPostProcessorType)
    
public  ObjectgetSpringBean(Object testObject, String name)
     Gets the spring bean with the given name.
public  ObjectgetSpringBeanByType(Object testObject, Class type)
     Gets the spring bean with the given type.
public  Set<SpringResourceTransactionManagerTransactionalConnectionHandler>getTransactionalConnectionHandlers()
    
public  voidinit(Properties configuration)
    
public  voidinjectApplicationContext(Object testObject)
     Gets the application context for this class and sets it on the fields and setter methods that are annotated with SpringApplicationContext .
public  voidinvalidateApplicationContext(Class... classes)
     Forces the reloading of the application context the next time that it is requested.
public  booleanisApplicationContextConfiguredFor(Object testObject)
    
public  voidregisterBeanPostProcessorType(Class<? extends BeanPostProcessor> beanPostProcessorType)
     Register a type of bean post processor.
public  voidregisterSpringResourceTransactionManagerTransactionalConnectionHandler(SpringResourceTransactionManagerTransactionalConnectionHandler transactionalConnectionHandler)
     Registers a SpringResourceTransactionManagerTransactionalConnectionHandler that defines how to retrieve a Connection, given the fact that we use a specific resource factory type.

Field Detail
PROPKEY_APPLICATION_CONTEXT_FACTORY_CLASS_NAME
final public static String PROPKEY_APPLICATION_CONTEXT_FACTORY_CLASS_NAME(Code)





Method Detail
assignSpringBeans
public void assignSpringBeans(Object testObject)(Code)
Gets the spring beans for all fields that are annotated with SpringBean .
Parameters:
  testObject - The test instance, not null



assignSpringBeansByName
public void assignSpringBeansByName(Object testObject)(Code)
Gets the spring beans for all fields that are annotated with SpringBeanByName .
Parameters:
  testObject - The test instance, not null



assignSpringBeansByType
public void assignSpringBeansByType(Object testObject)(Code)
Gets the spring beans for all fields methods that are annotated with SpringBeanByType .
Parameters:
  testObject - The test instance, not null



createTestListener
public TestListener createTestListener()(Code)
The TestListener for this module



getApplicationContext
public ApplicationContext getApplicationContext(Object testObject)(Code)
Gets the application context for this test. A new one will be created if it does not exist yet. If a superclass has also declared the creation of an application context, this one will be retrieved (or created if it was not created yet) and used as parent context for this classes context.

If needed, an application context will be created using the settings of the SpringApplicationContext annotation.

If a class level SpringApplicationContext annotation is found, the passed locations will be loaded using a ClassPathXmlApplicationContext. Custom creation methods can be created by annotating them with SpringApplicationContext . They should have an ApplicationContext as return type and either no or exactly 1 argument of type ApplicationContext. In the latter case, the current configured application context is passed as the argument.

A UnitilsException will be thrown if no context could be retrieved or created.
Parameters:
  testObject - The test instance, not null The application context, not null




getBeanPostProcessor
public T getBeanPostProcessor(Object testObject, Class<T> beanPostProcessorType)(Code)
<
Parameters:
  T - > The bean post processor type
Parameters:
  testObject - The test object
Parameters:
  beanPostProcessorType - Type bean post processor type The bean post processor of the given type that is associated with the application context that isin turn associated with the given test object



getSpringBean
public Object getSpringBean(Object testObject, String name)(Code)
Gets the spring bean with the given name. The given test instance, by using SpringApplicationContext , determines the application context in which to look for the bean.

A UnitilsException is thrown when the no bean could be found for the given name.
Parameters:
  testObject - The test instance, not null
Parameters:
  name - The name, not null The bean, not null




getSpringBeanByType
public Object getSpringBeanByType(Object testObject, Class type)(Code)
Gets the spring bean with the given type. The given test instance, by using SpringApplicationContext , determines the application context in which to look for the bean. If more there is not exactly 1 possible bean assignment, an UnitilsException will be thrown.
Parameters:
  testObject - The test instance, not null
Parameters:
  type - The type, not null The bean, not null



getTransactionalConnectionHandlers
public Set<SpringResourceTransactionManagerTransactionalConnectionHandler> getTransactionalConnectionHandlers()(Code)
All SpringResourceTransactionManagerTransactionalConnectionHandlers that were registered usingSpringModule.registerBeanPostProcessorType(Class)



init
public void init(Properties configuration)(Code)
Initializes this module using the given configuration
Parameters:
  configuration - The configuration, not null



injectApplicationContext
public void injectApplicationContext(Object testObject)(Code)
Gets the application context for this class and sets it on the fields and setter methods that are annotated with SpringApplicationContext . If no application context could be created, an UnitilsException will be raised.
Parameters:
  testObject - The test instance, not null



invalidateApplicationContext
public void invalidateApplicationContext(Class... classes)(Code)
Forces the reloading of the application context the next time that it is requested. If classes are given only contexts that are linked to those classes will be reset. If no classes are given, all cached contexts will be reset.
Parameters:
  classes - The classes for which to reset the contexts



isApplicationContextConfiguredFor
public boolean isApplicationContextConfiguredFor(Object testObject)(Code)

Parameters:
  testObject - The test object Whether an ApplicationContext has been configured for the given testObject



registerBeanPostProcessorType
public void registerBeanPostProcessorType(Class<? extends BeanPostProcessor> beanPostProcessorType)(Code)
Register a type of bean post processor. An instance of this bean post processor type will be used when loading an application context
Parameters:
  beanPostProcessorType -



registerSpringResourceTransactionManagerTransactionalConnectionHandler
public void registerSpringResourceTransactionManagerTransactionalConnectionHandler(SpringResourceTransactionManagerTransactionalConnectionHandler transactionalConnectionHandler)(Code)
Registers a SpringResourceTransactionManagerTransactionalConnectionHandler that defines how to retrieve a Connection, given the fact that we use a specific resource factory type.
Parameters:
  transactionalConnectionHandler -



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(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.