Package org.apache.wicket.spring.test
Class ApplicationContextMock
- java.lang.Object
-
- org.apache.wicket.spring.test.ApplicationContextMock
-
- All Implemented Interfaces:
java.io.Serializable,org.springframework.beans.factory.BeanFactory,org.springframework.beans.factory.HierarchicalBeanFactory,org.springframework.beans.factory.ListableBeanFactory,org.springframework.context.ApplicationContext,org.springframework.context.ApplicationEventPublisher,org.springframework.context.MessageSource,org.springframework.core.env.EnvironmentCapable,org.springframework.core.io.ResourceLoader,org.springframework.core.io.support.ResourcePatternResolver
public class ApplicationContextMock extends java.lang.Object implements org.springframework.context.ApplicationContext, java.io.SerializableMock application context object. This mock context allows easy creation of unit tests by allowing the user to put bean instances into the context. OnlygetBean(String),getBean(String, Class), andgetBeansOfType(Class)are implemented so far. Any other method throwsUnsupportedOperationException.- Author:
- Igor Vaynberg (ivaynberg)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ApplicationContextMock()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsBean(java.lang.String name)booleancontainsBeanDefinition(java.lang.String beanName)booleancontainsLocalBean(java.lang.String arg0)<A extends java.lang.annotation.Annotation>
AfindAnnotationOnBean(java.lang.String beanName, java.lang.Class<A> annotationType)java.lang.String[]getAliases(java.lang.String name)java.lang.StringgetApplicationName()org.springframework.beans.factory.config.AutowireCapableBeanFactorygetAutowireCapableBeanFactory()<T> TgetBean(java.lang.Class<T> requiredType)<T> TgetBean(java.lang.Class<T> requiredType, java.lang.Object... objects)java.lang.ObjectgetBean(java.lang.String name)<T> TgetBean(java.lang.String name, java.lang.Class<T> requiredType)java.lang.ObjectgetBean(java.lang.String name, java.lang.Object... args)intgetBeanDefinitionCount()java.lang.String[]getBeanDefinitionNames()java.lang.String[]getBeanNamesForAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> aClass)java.lang.String[]getBeanNamesForType(java.lang.Class type)java.lang.String[]getBeanNamesForType(java.lang.Class type, boolean includeNonSingletons, boolean allowEagerInit)java.lang.String[]getBeanNamesForType(org.springframework.core.ResolvableType resolvableType)<T> org.springframework.beans.factory.ObjectProvider<T>getBeanProvider(java.lang.Class<T> aClass)<T> org.springframework.beans.factory.ObjectProvider<T>getBeanProvider(org.springframework.core.ResolvableType resolvableType)<T> java.util.Map<java.lang.String,T>getBeansOfType(java.lang.Class<T> type)<T> java.util.Map<java.lang.String,T>getBeansOfType(java.lang.Class<T> type, boolean includeNonSingletons, boolean allowEagerInit)java.util.Map<java.lang.String,java.lang.Object>getBeansWithAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)java.lang.ClassLoadergetClassLoader()java.lang.StringgetDisplayName()org.springframework.core.env.EnvironmentgetEnvironment()java.lang.StringgetId()java.lang.StringgetMessage(java.lang.String code, java.lang.Object[] args, java.lang.String defaultMessage, java.util.Locale locale)java.lang.StringgetMessage(java.lang.String code, java.lang.Object[] args, java.util.Locale locale)java.lang.StringgetMessage(org.springframework.context.MessageSourceResolvable resolvable, java.util.Locale locale)org.springframework.context.ApplicationContextgetParent()org.springframework.beans.factory.BeanFactorygetParentBeanFactory()org.springframework.core.io.ResourcegetResource(java.lang.String location)org.springframework.core.io.Resource[]getResources(java.lang.String locationPattern)longgetStartupDate()java.lang.Class<?>getType(java.lang.String name)booleanisPrototype(java.lang.String name)booleanisSingleton(java.lang.String name)booleanisTypeMatch(java.lang.String name, java.lang.Class targetType)booleanisTypeMatch(java.lang.String s, org.springframework.core.ResolvableType resolvableType)voidpublishEvent(java.lang.Object o)voidpublishEvent(org.springframework.context.ApplicationEvent event)voidputBean(java.lang.Object bean)puts bean with into the context.voidputBean(java.lang.String name, java.lang.Object bean)puts bean with the given name into the context
-
-
-
Method Detail
-
putBean
public void putBean(java.lang.String name, java.lang.Object bean)puts bean with the given name into the context- Parameters:
name-bean-
-
putBean
public void putBean(java.lang.Object bean)
puts bean with into the context. bean object's class name will be used as the bean name.- Parameters:
bean-
-
getBean
public java.lang.Object getBean(java.lang.String name) throws org.springframework.beans.BeansException- Specified by:
getBeanin interfaceorg.springframework.beans.factory.BeanFactory- Throws:
org.springframework.beans.BeansException
-
getBean
public java.lang.Object getBean(java.lang.String name, java.lang.Object... args) throws org.springframework.beans.BeansException- Specified by:
getBeanin interfaceorg.springframework.beans.factory.BeanFactory- Throws:
org.springframework.beans.BeansException
-
getBean
public <T> T getBean(java.lang.String name, java.lang.Class<T> requiredType) throws org.springframework.beans.BeansException- Specified by:
getBeanin interfaceorg.springframework.beans.factory.BeanFactory- Throws:
org.springframework.beans.BeansException- See Also:
BeanFactory.getBean(java.lang.String, java.lang.Class)
-
getBeansOfType
public <T> java.util.Map<java.lang.String,T> getBeansOfType(java.lang.Class<T> type) throws org.springframework.beans.BeansException- Specified by:
getBeansOfTypein interfaceorg.springframework.beans.factory.ListableBeanFactory- Throws:
org.springframework.beans.BeansException- See Also:
ListableBeanFactory.getBeansOfType(java.lang.Class)
-
getBean
public <T> T getBean(java.lang.Class<T> requiredType) throws org.springframework.beans.BeansException- Specified by:
getBeanin interfaceorg.springframework.beans.factory.BeanFactory- Throws:
org.springframework.beans.BeansException
-
getBean
public <T> T getBean(java.lang.Class<T> requiredType, java.lang.Object... objects) throws org.springframework.beans.BeansException- Specified by:
getBeanin interfaceorg.springframework.beans.factory.BeanFactory- Throws:
org.springframework.beans.BeansException
-
getBeanProvider
public <T> org.springframework.beans.factory.ObjectProvider<T> getBeanProvider(java.lang.Class<T> aClass)
- Specified by:
getBeanProviderin interfaceorg.springframework.beans.factory.BeanFactory
-
getBeanProvider
public <T> org.springframework.beans.factory.ObjectProvider<T> getBeanProvider(org.springframework.core.ResolvableType resolvableType)
- Specified by:
getBeanProviderin interfaceorg.springframework.beans.factory.BeanFactory
-
getBeansWithAnnotation
public java.util.Map<java.lang.String,java.lang.Object> getBeansWithAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType) throws org.springframework.beans.BeansException- Specified by:
getBeansWithAnnotationin interfaceorg.springframework.beans.factory.ListableBeanFactory- Throws:
org.springframework.beans.BeansException
-
findAnnotationOnBean
public <A extends java.lang.annotation.Annotation> A findAnnotationOnBean(java.lang.String beanName, java.lang.Class<A> annotationType)- Specified by:
findAnnotationOnBeanin interfaceorg.springframework.beans.factory.ListableBeanFactory
-
getParent
public org.springframework.context.ApplicationContext getParent()
- Specified by:
getParentin interfaceorg.springframework.context.ApplicationContext
-
getDisplayName
public java.lang.String getDisplayName()
- Specified by:
getDisplayNamein interfaceorg.springframework.context.ApplicationContext
-
getStartupDate
public long getStartupDate()
- Specified by:
getStartupDatein interfaceorg.springframework.context.ApplicationContext
-
publishEvent
public void publishEvent(org.springframework.context.ApplicationEvent event)
- Specified by:
publishEventin interfaceorg.springframework.context.ApplicationEventPublisher
-
publishEvent
public void publishEvent(java.lang.Object o)
- Specified by:
publishEventin interfaceorg.springframework.context.ApplicationEventPublisher
-
containsBeanDefinition
public boolean containsBeanDefinition(java.lang.String beanName)
- Specified by:
containsBeanDefinitionin interfaceorg.springframework.beans.factory.ListableBeanFactory
-
getBeanDefinitionCount
public int getBeanDefinitionCount()
- Specified by:
getBeanDefinitionCountin interfaceorg.springframework.beans.factory.ListableBeanFactory
-
getBeanDefinitionNames
public java.lang.String[] getBeanDefinitionNames()
- Specified by:
getBeanDefinitionNamesin interfaceorg.springframework.beans.factory.ListableBeanFactory
-
getBeanNamesForType
public java.lang.String[] getBeanNamesForType(org.springframework.core.ResolvableType resolvableType)
- Specified by:
getBeanNamesForTypein interfaceorg.springframework.beans.factory.ListableBeanFactory
-
getBeanNamesForType
public java.lang.String[] getBeanNamesForType(java.lang.Class type)
- Specified by:
getBeanNamesForTypein interfaceorg.springframework.beans.factory.ListableBeanFactory
-
getBeanNamesForType
public java.lang.String[] getBeanNamesForType(java.lang.Class type, boolean includeNonSingletons, boolean allowEagerInit)- Specified by:
getBeanNamesForTypein interfaceorg.springframework.beans.factory.ListableBeanFactory
-
getBeansOfType
public <T> java.util.Map<java.lang.String,T> getBeansOfType(java.lang.Class<T> type, boolean includeNonSingletons, boolean allowEagerInit) throws org.springframework.beans.BeansException- Specified by:
getBeansOfTypein interfaceorg.springframework.beans.factory.ListableBeanFactory- Throws:
org.springframework.beans.BeansException
-
getBeanNamesForAnnotation
public java.lang.String[] getBeanNamesForAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> aClass)
- Specified by:
getBeanNamesForAnnotationin interfaceorg.springframework.beans.factory.ListableBeanFactory
-
containsBean
public boolean containsBean(java.lang.String name)
- Specified by:
containsBeanin interfaceorg.springframework.beans.factory.BeanFactory
-
isSingleton
public boolean isSingleton(java.lang.String name) throws org.springframework.beans.factory.NoSuchBeanDefinitionException- Specified by:
isSingletonin interfaceorg.springframework.beans.factory.BeanFactory- Throws:
org.springframework.beans.factory.NoSuchBeanDefinitionException
-
getType
public java.lang.Class<?> getType(java.lang.String name) throws org.springframework.beans.factory.NoSuchBeanDefinitionException- Specified by:
getTypein interfaceorg.springframework.beans.factory.BeanFactory- Throws:
org.springframework.beans.factory.NoSuchBeanDefinitionException
-
getAliases
public java.lang.String[] getAliases(java.lang.String name) throws org.springframework.beans.factory.NoSuchBeanDefinitionException- Specified by:
getAliasesin interfaceorg.springframework.beans.factory.BeanFactory- Throws:
org.springframework.beans.factory.NoSuchBeanDefinitionException
-
getParentBeanFactory
public org.springframework.beans.factory.BeanFactory getParentBeanFactory()
- Specified by:
getParentBeanFactoryin interfaceorg.springframework.beans.factory.HierarchicalBeanFactory
-
getMessage
public java.lang.String getMessage(java.lang.String code, java.lang.Object[] args, java.lang.String defaultMessage, java.util.Locale locale)- Specified by:
getMessagein interfaceorg.springframework.context.MessageSource
-
getMessage
public java.lang.String getMessage(java.lang.String code, java.lang.Object[] args, java.util.Locale locale) throws org.springframework.context.NoSuchMessageException- Specified by:
getMessagein interfaceorg.springframework.context.MessageSource- Throws:
org.springframework.context.NoSuchMessageException
-
getMessage
public java.lang.String getMessage(org.springframework.context.MessageSourceResolvable resolvable, java.util.Locale locale) throws org.springframework.context.NoSuchMessageException- Specified by:
getMessagein interfaceorg.springframework.context.MessageSource- Throws:
org.springframework.context.NoSuchMessageException
-
getResources
public org.springframework.core.io.Resource[] getResources(java.lang.String locationPattern) throws java.io.IOException- Specified by:
getResourcesin interfaceorg.springframework.core.io.support.ResourcePatternResolver- Throws:
java.io.IOException
-
getResource
public org.springframework.core.io.Resource getResource(java.lang.String location)
- Specified by:
getResourcein interfaceorg.springframework.core.io.ResourceLoader
-
getAutowireCapableBeanFactory
public org.springframework.beans.factory.config.AutowireCapableBeanFactory getAutowireCapableBeanFactory() throws java.lang.IllegalStateException- Specified by:
getAutowireCapableBeanFactoryin interfaceorg.springframework.context.ApplicationContext- Throws:
java.lang.IllegalStateException
-
containsLocalBean
public boolean containsLocalBean(java.lang.String arg0)
- Specified by:
containsLocalBeanin interfaceorg.springframework.beans.factory.HierarchicalBeanFactory
-
getClassLoader
public java.lang.ClassLoader getClassLoader()
- Specified by:
getClassLoaderin interfaceorg.springframework.core.io.ResourceLoader
-
getId
public java.lang.String getId()
- Specified by:
getIdin interfaceorg.springframework.context.ApplicationContext
-
getApplicationName
public java.lang.String getApplicationName()
- Specified by:
getApplicationNamein interfaceorg.springframework.context.ApplicationContext
-
isPrototype
public boolean isPrototype(java.lang.String name) throws org.springframework.beans.factory.NoSuchBeanDefinitionException- Specified by:
isPrototypein interfaceorg.springframework.beans.factory.BeanFactory- Throws:
org.springframework.beans.factory.NoSuchBeanDefinitionException
-
isTypeMatch
public boolean isTypeMatch(java.lang.String s, org.springframework.core.ResolvableType resolvableType) throws org.springframework.beans.factory.NoSuchBeanDefinitionException- Specified by:
isTypeMatchin interfaceorg.springframework.beans.factory.BeanFactory- Throws:
org.springframework.beans.factory.NoSuchBeanDefinitionException
-
isTypeMatch
public boolean isTypeMatch(java.lang.String name, java.lang.Class targetType) throws org.springframework.beans.factory.NoSuchBeanDefinitionException- Specified by:
isTypeMatchin interfaceorg.springframework.beans.factory.BeanFactory- Throws:
org.springframework.beans.factory.NoSuchBeanDefinitionException
-
getEnvironment
public org.springframework.core.env.Environment getEnvironment()
- Specified by:
getEnvironmentin interfaceorg.springframework.core.env.EnvironmentCapable
-
-