Package com.vaadin.testbench.unit.mocks
Class MockWebApplicationContext
java.lang.Object
com.vaadin.testbench.unit.mocks.MockWebApplicationContext
- All Implemented Interfaces:
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
,org.springframework.web.context.WebApplicationContext
public class MockWebApplicationContext
extends Object
implements org.springframework.web.context.WebApplicationContext
An adapter to make a generic Spring ApplicationContext act like a
WebApplicationContext.
For internal use only.
-
Field Summary
Fields inherited from interface org.springframework.beans.factory.BeanFactory
FACTORY_BEAN_PREFIX
Fields inherited from interface org.springframework.core.io.ResourceLoader
CLASSPATH_URL_PREFIX
Fields inherited from interface org.springframework.core.io.support.ResourcePatternResolver
CLASSPATH_ALL_URL_PREFIX
Fields inherited from interface org.springframework.web.context.WebApplicationContext
CONTEXT_ATTRIBUTES_BEAN_NAME, CONTEXT_PARAMETERS_BEAN_NAME, ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, SCOPE_APPLICATION, SCOPE_REQUEST, SCOPE_SESSION, SERVLET_CONTEXT_BEAN_NAME
-
Constructor Summary
ConstructorsConstructorDescriptionMockWebApplicationContext
(org.springframework.context.ApplicationContext appCtx, jakarta.servlet.ServletContext servletContext) -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsBean
(String name) boolean
containsBeanDefinition
(String beanName) boolean
containsLocalBean
(String name) <A extends Annotation>
Set<A>findAllAnnotationsOnBean
(String beanName, Class<A> annotationType, boolean allowFactoryBeanInit) <A extends Annotation>
AfindAnnotationOnBean
(String beanName, Class<A> annotationType) <A extends Annotation>
AfindAnnotationOnBean
(String beanName, Class<A> annotationType, boolean allowFactoryBeanInit) String[]
getAliases
(String name) org.springframework.beans.factory.config.AutowireCapableBeanFactory
<T> T
<T> T
<T> T
int
String[]
String[]
getBeanNamesForAnnotation
(Class<? extends Annotation> annotationType) String[]
getBeanNamesForType
(Class<?> type) String[]
getBeanNamesForType
(Class<?> type, boolean includeNonSingletons, boolean allowEagerInit) String[]
getBeanNamesForType
(org.springframework.core.ResolvableType type) String[]
getBeanNamesForType
(org.springframework.core.ResolvableType type, boolean includeNonSingletons, boolean allowEagerInit) <T> org.springframework.beans.factory.ObjectProvider<T>
getBeanProvider
(Class<T> requiredType) <T> org.springframework.beans.factory.ObjectProvider<T>
getBeanProvider
(Class<T> requiredType, boolean allowEagerInit) <T> org.springframework.beans.factory.ObjectProvider<T>
getBeanProvider
(org.springframework.core.ResolvableType requiredType) <T> org.springframework.beans.factory.ObjectProvider<T>
getBeanProvider
(org.springframework.core.ResolvableType requiredType, boolean allowEagerInit) getBeansOfType
(Class<T> type) getBeansOfType
(Class<T> type, boolean includeNonSingletons, boolean allowEagerInit) getBeansWithAnnotation
(Class<? extends Annotation> annotationType) org.springframework.core.env.Environment
getId()
getMessage
(String code, Object[] args, String defaultMessage, Locale locale) getMessage
(String code, Object[] args, Locale locale) getMessage
(org.springframework.context.MessageSourceResolvable resolvable, Locale locale) org.springframework.context.ApplicationContext
org.springframework.beans.factory.BeanFactory
org.springframework.core.io.Resource
getResource
(String location) org.springframework.core.io.Resource[]
getResources
(String locationPattern) jakarta.servlet.ServletContext
long
Class<?>
Class<?>
boolean
isPrototype
(String name) boolean
isSingleton
(String name) boolean
isTypeMatch
(String name, Class<?> typeToMatch) boolean
isTypeMatch
(String name, org.springframework.core.ResolvableType typeToMatch) void
publishEvent
(Object event) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.context.ApplicationEventPublisher
publishEvent
-
Constructor Details
-
MockWebApplicationContext
public MockWebApplicationContext(org.springframework.context.ApplicationContext appCtx, jakarta.servlet.ServletContext servletContext)
-
-
Method Details
-
getServletContext
public jakarta.servlet.ServletContext getServletContext()- Specified by:
getServletContext
in interfaceorg.springframework.web.context.WebApplicationContext
-
getId
- Specified by:
getId
in interfaceorg.springframework.context.ApplicationContext
-
getApplicationName
- Specified by:
getApplicationName
in interfaceorg.springframework.context.ApplicationContext
-
getDisplayName
- Specified by:
getDisplayName
in interfaceorg.springframework.context.ApplicationContext
-
getStartupDate
public long getStartupDate()- Specified by:
getStartupDate
in interfaceorg.springframework.context.ApplicationContext
-
getParent
public org.springframework.context.ApplicationContext getParent()- Specified by:
getParent
in interfaceorg.springframework.context.ApplicationContext
-
getAutowireCapableBeanFactory
public org.springframework.beans.factory.config.AutowireCapableBeanFactory getAutowireCapableBeanFactory() throws IllegalStateException- Specified by:
getAutowireCapableBeanFactory
in interfaceorg.springframework.context.ApplicationContext
- Throws:
IllegalStateException
-
getParentBeanFactory
public org.springframework.beans.factory.BeanFactory getParentBeanFactory()- Specified by:
getParentBeanFactory
in interfaceorg.springframework.beans.factory.HierarchicalBeanFactory
-
containsLocalBean
- Specified by:
containsLocalBean
in interfaceorg.springframework.beans.factory.HierarchicalBeanFactory
-
containsBeanDefinition
- Specified by:
containsBeanDefinition
in interfaceorg.springframework.beans.factory.ListableBeanFactory
-
getBeanDefinitionCount
public int getBeanDefinitionCount()- Specified by:
getBeanDefinitionCount
in interfaceorg.springframework.beans.factory.ListableBeanFactory
-
getBeanDefinitionNames
- Specified by:
getBeanDefinitionNames
in interfaceorg.springframework.beans.factory.ListableBeanFactory
-
getBeanProvider
public <T> org.springframework.beans.factory.ObjectProvider<T> getBeanProvider(Class<T> requiredType, boolean allowEagerInit) - Specified by:
getBeanProvider
in interfaceorg.springframework.beans.factory.ListableBeanFactory
-
getBeanProvider
public <T> org.springframework.beans.factory.ObjectProvider<T> getBeanProvider(org.springframework.core.ResolvableType requiredType, boolean allowEagerInit) - Specified by:
getBeanProvider
in interfaceorg.springframework.beans.factory.ListableBeanFactory
-
getBeanNamesForType
- Specified by:
getBeanNamesForType
in interfaceorg.springframework.beans.factory.ListableBeanFactory
-
getBeanNamesForType
public String[] getBeanNamesForType(org.springframework.core.ResolvableType type, boolean includeNonSingletons, boolean allowEagerInit) - Specified by:
getBeanNamesForType
in interfaceorg.springframework.beans.factory.ListableBeanFactory
-
getBeanNamesForType
- Specified by:
getBeanNamesForType
in interfaceorg.springframework.beans.factory.ListableBeanFactory
-
getBeanNamesForType
public String[] getBeanNamesForType(Class<?> type, boolean includeNonSingletons, boolean allowEagerInit) - Specified by:
getBeanNamesForType
in interfaceorg.springframework.beans.factory.ListableBeanFactory
-
getBeansOfType
public <T> Map<String,T> getBeansOfType(Class<T> type) throws org.springframework.beans.BeansException - Specified by:
getBeansOfType
in interfaceorg.springframework.beans.factory.ListableBeanFactory
- Throws:
org.springframework.beans.BeansException
-
getBeansOfType
public <T> Map<String,T> getBeansOfType(Class<T> type, boolean includeNonSingletons, boolean allowEagerInit) throws org.springframework.beans.BeansException - Specified by:
getBeansOfType
in interfaceorg.springframework.beans.factory.ListableBeanFactory
- Throws:
org.springframework.beans.BeansException
-
getBeanNamesForAnnotation
- Specified by:
getBeanNamesForAnnotation
in interfaceorg.springframework.beans.factory.ListableBeanFactory
-
getBeansWithAnnotation
public Map<String,Object> getBeansWithAnnotation(Class<? extends Annotation> annotationType) throws org.springframework.beans.BeansException - Specified by:
getBeansWithAnnotation
in interfaceorg.springframework.beans.factory.ListableBeanFactory
- Throws:
org.springframework.beans.BeansException
-
findAnnotationOnBean
public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType) throws org.springframework.beans.factory.NoSuchBeanDefinitionException - Specified by:
findAnnotationOnBean
in interfaceorg.springframework.beans.factory.ListableBeanFactory
- Throws:
org.springframework.beans.factory.NoSuchBeanDefinitionException
-
findAnnotationOnBean
public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType, boolean allowFactoryBeanInit) throws org.springframework.beans.factory.NoSuchBeanDefinitionException - Specified by:
findAnnotationOnBean
in interfaceorg.springframework.beans.factory.ListableBeanFactory
- Throws:
org.springframework.beans.factory.NoSuchBeanDefinitionException
-
getBean
- Specified by:
getBean
in interfaceorg.springframework.beans.factory.BeanFactory
- Throws:
org.springframework.beans.BeansException
-
getBean
public <T> T getBean(String name, Class<T> requiredType) throws org.springframework.beans.BeansException - Specified by:
getBean
in interfaceorg.springframework.beans.factory.BeanFactory
- Throws:
org.springframework.beans.BeansException
-
getBean
- Specified by:
getBean
in interfaceorg.springframework.beans.factory.BeanFactory
- Throws:
org.springframework.beans.BeansException
-
getBean
- Specified by:
getBean
in interfaceorg.springframework.beans.factory.BeanFactory
- Throws:
org.springframework.beans.BeansException
-
getBean
public <T> T getBean(Class<T> requiredType, Object... args) throws org.springframework.beans.BeansException - Specified by:
getBean
in interfaceorg.springframework.beans.factory.BeanFactory
- Throws:
org.springframework.beans.BeansException
-
getBeanProvider
public <T> org.springframework.beans.factory.ObjectProvider<T> getBeanProvider(Class<T> requiredType) - Specified by:
getBeanProvider
in interfaceorg.springframework.beans.factory.BeanFactory
-
getBeanProvider
public <T> org.springframework.beans.factory.ObjectProvider<T> getBeanProvider(org.springframework.core.ResolvableType requiredType) - Specified by:
getBeanProvider
in interfaceorg.springframework.beans.factory.BeanFactory
-
containsBean
- Specified by:
containsBean
in interfaceorg.springframework.beans.factory.BeanFactory
-
isSingleton
public boolean isSingleton(String name) throws org.springframework.beans.factory.NoSuchBeanDefinitionException - Specified by:
isSingleton
in interfaceorg.springframework.beans.factory.BeanFactory
- Throws:
org.springframework.beans.factory.NoSuchBeanDefinitionException
-
isPrototype
public boolean isPrototype(String name) throws org.springframework.beans.factory.NoSuchBeanDefinitionException - Specified by:
isPrototype
in interfaceorg.springframework.beans.factory.BeanFactory
- Throws:
org.springframework.beans.factory.NoSuchBeanDefinitionException
-
isTypeMatch
public boolean isTypeMatch(String name, org.springframework.core.ResolvableType typeToMatch) throws org.springframework.beans.factory.NoSuchBeanDefinitionException - Specified by:
isTypeMatch
in interfaceorg.springframework.beans.factory.BeanFactory
- Throws:
org.springframework.beans.factory.NoSuchBeanDefinitionException
-
isTypeMatch
public boolean isTypeMatch(String name, Class<?> typeToMatch) throws org.springframework.beans.factory.NoSuchBeanDefinitionException - Specified by:
isTypeMatch
in interfaceorg.springframework.beans.factory.BeanFactory
- Throws:
org.springframework.beans.factory.NoSuchBeanDefinitionException
-
getType
public Class<?> getType(String name) throws org.springframework.beans.factory.NoSuchBeanDefinitionException - Specified by:
getType
in interfaceorg.springframework.beans.factory.BeanFactory
- Throws:
org.springframework.beans.factory.NoSuchBeanDefinitionException
-
getType
public Class<?> getType(String name, boolean allowFactoryBeanInit) throws org.springframework.beans.factory.NoSuchBeanDefinitionException - Specified by:
getType
in interfaceorg.springframework.beans.factory.BeanFactory
- Throws:
org.springframework.beans.factory.NoSuchBeanDefinitionException
-
getAliases
- Specified by:
getAliases
in interfaceorg.springframework.beans.factory.BeanFactory
-
publishEvent
- Specified by:
publishEvent
in interfaceorg.springframework.context.ApplicationEventPublisher
-
getMessage
- Specified by:
getMessage
in interfaceorg.springframework.context.MessageSource
-
getMessage
public String getMessage(String code, Object[] args, Locale locale) throws org.springframework.context.NoSuchMessageException - Specified by:
getMessage
in interfaceorg.springframework.context.MessageSource
- Throws:
org.springframework.context.NoSuchMessageException
-
getMessage
public String getMessage(org.springframework.context.MessageSourceResolvable resolvable, Locale locale) throws org.springframework.context.NoSuchMessageException - Specified by:
getMessage
in interfaceorg.springframework.context.MessageSource
- Throws:
org.springframework.context.NoSuchMessageException
-
getEnvironment
public org.springframework.core.env.Environment getEnvironment()- Specified by:
getEnvironment
in interfaceorg.springframework.core.env.EnvironmentCapable
-
getResources
public org.springframework.core.io.Resource[] getResources(String locationPattern) throws IOException - Specified by:
getResources
in interfaceorg.springframework.core.io.support.ResourcePatternResolver
- Throws:
IOException
-
getResource
- Specified by:
getResource
in interfaceorg.springframework.core.io.ResourceLoader
-
getClassLoader
- Specified by:
getClassLoader
in interfaceorg.springframework.core.io.ResourceLoader
-
findAllAnnotationsOnBean
public <A extends Annotation> Set<A> findAllAnnotationsOnBean(String beanName, Class<A> annotationType, boolean allowFactoryBeanInit) throws org.springframework.beans.factory.NoSuchBeanDefinitionException - Specified by:
findAllAnnotationsOnBean
in interfaceorg.springframework.beans.factory.ListableBeanFactory
- Throws:
org.springframework.beans.factory.NoSuchBeanDefinitionException
-