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, FACTORY_BEAN_PREFIX_CHARFields inherited from interface org.springframework.core.io.ResourceLoader
CLASSPATH_URL_PREFIXFields inherited from interface org.springframework.core.io.support.ResourcePatternResolver
CLASSPATH_ALL_URL_PREFIXFields 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 TypeMethodDescriptionbooleancontainsBean(String name) booleancontainsBeanDefinition(String beanName) booleancontainsLocalBean(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> TintString[]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.ParameterizedTypeReference<T> reference) <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.EnvironmentgetId()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.ApplicationContextorg.springframework.beans.factory.BeanFactoryorg.springframework.core.io.ResourcegetResource(String location) org.springframework.core.io.Resource[]getResources(String locationPattern) jakarta.servlet.ServletContextlongClass<?> Class<?> booleanisPrototype(String name) booleanisSingleton(String name) booleanisTypeMatch(String name, Class<?> typeToMatch) booleanisTypeMatch(String name, org.springframework.core.ResolvableType typeToMatch) voidpublishEvent(Object event) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:
getServletContextin interfaceorg.springframework.web.context.WebApplicationContext
-
getId
- Specified by:
getIdin interfaceorg.springframework.context.ApplicationContext
-
getApplicationName
- Specified by:
getApplicationNamein interfaceorg.springframework.context.ApplicationContext
-
getDisplayName
- Specified by:
getDisplayNamein interfaceorg.springframework.context.ApplicationContext
-
getStartupDate
public long getStartupDate()- Specified by:
getStartupDatein interfaceorg.springframework.context.ApplicationContext
-
getParent
public org.springframework.context.ApplicationContext getParent()- Specified by:
getParentin interfaceorg.springframework.context.ApplicationContext
-
getAutowireCapableBeanFactory
public org.springframework.beans.factory.config.AutowireCapableBeanFactory getAutowireCapableBeanFactory() throws IllegalStateException- Specified by:
getAutowireCapableBeanFactoryin interfaceorg.springframework.context.ApplicationContext- Throws:
IllegalStateException
-
getParentBeanFactory
public org.springframework.beans.factory.BeanFactory getParentBeanFactory()- Specified by:
getParentBeanFactoryin interfaceorg.springframework.beans.factory.HierarchicalBeanFactory
-
containsLocalBean
- Specified by:
containsLocalBeanin interfaceorg.springframework.beans.factory.HierarchicalBeanFactory
-
containsBeanDefinition
- Specified by:
containsBeanDefinitionin interfaceorg.springframework.beans.factory.ListableBeanFactory
-
getBeanDefinitionCount
public int getBeanDefinitionCount()- Specified by:
getBeanDefinitionCountin interfaceorg.springframework.beans.factory.ListableBeanFactory
-
getBeanDefinitionNames
- Specified by:
getBeanDefinitionNamesin interfaceorg.springframework.beans.factory.ListableBeanFactory
-
getBeanProvider
public <T> org.springframework.beans.factory.ObjectProvider<T> getBeanProvider(Class<T> requiredType, boolean allowEagerInit) - Specified by:
getBeanProviderin interfaceorg.springframework.beans.factory.ListableBeanFactory
-
getBeanProvider
public <T> org.springframework.beans.factory.ObjectProvider<T> getBeanProvider(org.springframework.core.ResolvableType requiredType, boolean allowEagerInit) - Specified by:
getBeanProviderin interfaceorg.springframework.beans.factory.ListableBeanFactory
-
getBeanProvider
public <T> org.springframework.beans.factory.ObjectProvider<T> getBeanProvider(org.springframework.core.ParameterizedTypeReference<T> reference) - Specified by:
getBeanProviderin interfaceorg.springframework.beans.factory.BeanFactory
-
getBeanNamesForType
- Specified by:
getBeanNamesForTypein interfaceorg.springframework.beans.factory.ListableBeanFactory
-
getBeanNamesForType
public String[] getBeanNamesForType(org.springframework.core.ResolvableType type, boolean includeNonSingletons, boolean allowEagerInit) - Specified by:
getBeanNamesForTypein interfaceorg.springframework.beans.factory.ListableBeanFactory
-
getBeanNamesForType
- Specified by:
getBeanNamesForTypein interfaceorg.springframework.beans.factory.ListableBeanFactory
-
getBeanNamesForType
public String[] getBeanNamesForType(Class<?> type, boolean includeNonSingletons, boolean allowEagerInit) - Specified by:
getBeanNamesForTypein interfaceorg.springframework.beans.factory.ListableBeanFactory
-
getBeansOfType
public <T> Map<String,T> getBeansOfType(Class<T> type) throws org.springframework.beans.BeansException - Specified by:
getBeansOfTypein 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:
getBeansOfTypein interfaceorg.springframework.beans.factory.ListableBeanFactory- Throws:
org.springframework.beans.BeansException
-
getBeanNamesForAnnotation
- Specified by:
getBeanNamesForAnnotationin interfaceorg.springframework.beans.factory.ListableBeanFactory
-
getBeansWithAnnotation
public Map<String,Object> getBeansWithAnnotation(Class<? extends Annotation> annotationType) throws org.springframework.beans.BeansException - Specified by:
getBeansWithAnnotationin 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:
findAnnotationOnBeanin 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:
findAnnotationOnBeanin interfaceorg.springframework.beans.factory.ListableBeanFactory- Throws:
org.springframework.beans.factory.NoSuchBeanDefinitionException
-
getBean
- Specified by:
getBeanin 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:
getBeanin interfaceorg.springframework.beans.factory.BeanFactory- Throws:
org.springframework.beans.BeansException
-
getBean
- Specified by:
getBeanin interfaceorg.springframework.beans.factory.BeanFactory- Throws:
org.springframework.beans.BeansException
-
getBean
- Specified by:
getBeanin 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:
getBeanin 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:
getBeanProviderin interfaceorg.springframework.beans.factory.BeanFactory
-
getBeanProvider
public <T> org.springframework.beans.factory.ObjectProvider<T> getBeanProvider(org.springframework.core.ResolvableType requiredType) - Specified by:
getBeanProviderin interfaceorg.springframework.beans.factory.BeanFactory
-
containsBean
- Specified by:
containsBeanin interfaceorg.springframework.beans.factory.BeanFactory
-
isSingleton
public boolean isSingleton(String name) throws org.springframework.beans.factory.NoSuchBeanDefinitionException - Specified by:
isSingletonin 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:
isPrototypein 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:
isTypeMatchin 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:
isTypeMatchin 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:
getTypein 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:
getTypein interfaceorg.springframework.beans.factory.BeanFactory- Throws:
org.springframework.beans.factory.NoSuchBeanDefinitionException
-
getAliases
- Specified by:
getAliasesin interfaceorg.springframework.beans.factory.BeanFactory
-
publishEvent
- Specified by:
publishEventin interfaceorg.springframework.context.ApplicationEventPublisher
-
getMessage
- Specified by:
getMessagein interfaceorg.springframework.context.MessageSource
-
getMessage
public String getMessage(String code, Object[] args, Locale locale) throws org.springframework.context.NoSuchMessageException - Specified by:
getMessagein 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:
getMessagein interfaceorg.springframework.context.MessageSource- Throws:
org.springframework.context.NoSuchMessageException
-
getEnvironment
public org.springframework.core.env.Environment getEnvironment()- Specified by:
getEnvironmentin interfaceorg.springframework.core.env.EnvironmentCapable
-
getResources
public org.springframework.core.io.Resource[] getResources(String locationPattern) throws IOException - Specified by:
getResourcesin interfaceorg.springframework.core.io.support.ResourcePatternResolver- Throws:
IOException
-
getResource
- Specified by:
getResourcein interfaceorg.springframework.core.io.ResourceLoader
-
getClassLoader
- Specified by:
getClassLoaderin 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:
findAllAnnotationsOnBeanin interfaceorg.springframework.beans.factory.ListableBeanFactory- Throws:
org.springframework.beans.factory.NoSuchBeanDefinitionException
-