org.unitils.spring.profile
Class ProfileModule

java.lang.Object
  extended by org.unitils.spring.profile.ProfileModule
All Implemented Interfaces:
Module

public class ProfileModule
extends Object
implements Module

ProfileModule - Since Spring 3 their is the ability to use a profile. But without Unitils you still need to do some configuration. This module configures the Spring profile and reload the SpringApplicationContext.

Since:
3.4
Author:
Jeroen Horemans, Thomas De Rycke, Willemijn Wouters

Constructor Summary
ProfileModule()
           
 
Method Summary
 void afterInit()
           
protected  boolean checkIfEverythingIsInPlace(Class<?> testClass)
          This method checks if the testclass contains a SpringApplicationContext and a ConfigureProfile.
protected  void closeContext()
          The context will be closed.
protected  org.springframework.context.support.GenericApplicationContext getCtx()
           
protected  void getProfile(Class<?> testClass)
          First it will look if the ConfigureProfile is present.
 TestListener getTestListener()
           
 void init(Properties configuration)
           
 boolean injectBeans(Object testObject)
          The injection of beans doesn't happen automatically anymore when you use SpringBeanByName or SpringBeanByType
protected  void setConfigurationAsTypeConfiguration(org.springframework.context.annotation.AnnotationConfigApplicationContext ctx, ConfigureProfile profile)
          How to do the configuration when you use Configuration
protected  void setConfigurationAsTypeSpringApplicationContext(org.springframework.context.support.GenericXmlApplicationContext ctx, ConfigureProfile profile, String[] placeContext)
           
protected  void setCtx(org.springframework.context.support.GenericApplicationContext ctx)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProfileModule

public ProfileModule()
Method Detail

init

public void init(Properties configuration)
Specified by:
init in interface Module
See Also:
Module.init(java.util.Properties)

afterInit

public void afterInit()
Specified by:
afterInit in interface Module
See Also:
Module.afterInit()

getProfile

protected void getProfile(Class<?> testClass)
First it will look if the ConfigureProfile is present. This annotation contains the profilename. The Profile is set active and all the beans will be loaded.

Parameters:
testClass -

setConfigurationAsTypeConfiguration

protected void setConfigurationAsTypeConfiguration(org.springframework.context.annotation.AnnotationConfigApplicationContext ctx,
                                                   ConfigureProfile profile)
How to do the configuration when you use Configuration

Parameters:
ctx -
profile -

setConfigurationAsTypeSpringApplicationContext

protected void setConfigurationAsTypeSpringApplicationContext(org.springframework.context.support.GenericXmlApplicationContext ctx,
                                                              ConfigureProfile profile,
                                                              String[] placeContext)

injectBeans

public boolean injectBeans(Object testObject)
The injection of beans doesn't happen automatically anymore when you use SpringBeanByName or SpringBeanByType

Parameters:
testObject -

checkIfEverythingIsInPlace

protected boolean checkIfEverythingIsInPlace(Class<?> testClass)
This method checks if the testclass contains a SpringApplicationContext and a ConfigureProfile.

Parameters:
testClass -
Returns:
boolean

setCtx

protected void setCtx(org.springframework.context.support.GenericApplicationContext ctx)
Parameters:
ctx - the ctx to set

getCtx

protected org.springframework.context.support.GenericApplicationContext getCtx()
Returns:
the ctx

closeContext

protected void closeContext()
The context will be closed.


getTestListener

public TestListener getTestListener()
Specified by:
getTestListener in interface Module
See Also:
Module.getTestListener()


Copyright © 2014. All Rights Reserved.