org.easetech.easytest.util
Class ConfigContext

java.lang.Object
  extended by org.easetech.easytest.util.ConfigContext

public final class ConfigContext
extends Object

A context class for holding the Configuration beans declared by the user. This class provides a utility for the EasyTest framework to identify a test bean declared using TestBean annotations inside a class that is declared in the test class using TestConfigProvider

Author:
Anuj Kumar

Field Summary
static ThreadLocal<Map<String,Object>> beansByName
          The threadlocal variable that is responsible for containing the bean name to object instance mapping
static ThreadLocal<Map<Class,Object>> beansByType
          The threadlocal variable that is responsible for containing the bean type to object instance mapping
 
Method Summary
static Object getBeanByName(String beanName)
          Get the test bean by name.
static Object getBeanByType(Class beanType)
          Get the test bean by type
static void setTestBeanByName(String beanName, Object beanInstance)
          Set the test bean in the thread local variable by name
static void setTestBeanByType(Class beanType, Object beanInstance)
          Set the test bean in the threadlocal variable by type
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

beansByName

public static final ThreadLocal<Map<String,Object>> beansByName
The threadlocal variable that is responsible for containing the bean name to object instance mapping


beansByType

public static final ThreadLocal<Map<Class,Object>> beansByType
The threadlocal variable that is responsible for containing the bean type to object instance mapping

Method Detail

setTestBeanByName

public static void setTestBeanByName(String beanName,
                                     Object beanInstance)
Set the test bean in the thread local variable by name

Parameters:
beanName - the name of the bean
beanInstance - the instance to set

setTestBeanByType

public static void setTestBeanByType(Class beanType,
                                     Object beanInstance)
Set the test bean in the threadlocal variable by type

Parameters:
beanType - the type of the bean
beanInstance - the instance to set

getBeanByName

public static Object getBeanByName(String beanName)
Get the test bean by name.

Parameters:
beanName - the name of the bean to get value for
Returns:
the bean instance or null if not found

getBeanByType

public static Object getBeanByType(Class beanType)
Get the test bean by type

Parameters:
beanType - the type of bean to get
Returns:
the instance of the bean


Copyright © 2013. All Rights Reserved.