org.codehaus.groovy.grails.support
Class MockApplicationContext

java.lang.Object
  extended by groovy.lang.GroovyObjectSupport
      extended by org.codehaus.groovy.grails.support.MockApplicationContext
All Implemented Interfaces:
groovy.lang.GroovyObject, 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.io.ResourceLoader, org.springframework.core.io.support.ResourcePatternResolver, org.springframework.web.context.WebApplicationContext

public class MockApplicationContext
extends groovy.lang.GroovyObjectSupport
implements org.springframework.web.context.WebApplicationContext


Nested Class Summary
 class MockApplicationContext.MockResource
           
 
Field Summary
(package private)  java.util.Map beans
           
(package private)  java.util.List ignoredClassLocations
           
(package private)  org.springframework.util.PathMatcher pathMatcher
           
(package private)  java.util.List resources
           
(package private)  java.util.Date startupDate
           
 
Fields inherited from interface org.springframework.web.context.WebApplicationContext
ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, SCOPE_GLOBAL_SESSION, SCOPE_REQUEST, SCOPE_SESSION
 
Fields inherited from interface org.springframework.beans.factory.BeanFactory
FACTORY_BEAN_PREFIX
 
Fields inherited from interface org.springframework.core.io.support.ResourcePatternResolver
CLASSPATH_ALL_URL_PREFIX
 
Fields inherited from interface org.springframework.core.io.ResourceLoader
CLASSPATH_URL_PREFIX
 
Constructor Summary
MockApplicationContext()
           
 
Method Summary
 boolean containsBean(java.lang.String name)
           
 boolean containsBeanDefinition(java.lang.String beanName)
           
 boolean containsLocalBean(java.lang.String arg0)
           
 java.lang.String[] getAliases(java.lang.String name)
           
 org.springframework.beans.factory.config.AutowireCapableBeanFactory getAutowireCapableBeanFactory()
           
 java.lang.Object getBean(java.lang.String name)
           
 java.lang.Object getBean(java.lang.String name, java.lang.Class requiredType)
           
 java.lang.Object getBean(java.lang.String name, java.lang.Object[] args)
           
 int getBeanDefinitionCount()
           
 java.lang.String[] getBeanDefinitionNames()
           
 java.lang.String[] getBeanDefinitionNames(java.lang.Class type)
           
 java.lang.String[] getBeanNamesForType(java.lang.Class type)
           
 java.lang.String[] getBeanNamesForType(java.lang.Class type, boolean includePrototypes, boolean includeFactoryBeans)
           
 java.util.Map getBeansOfType(java.lang.Class type)
           
 java.util.Map getBeansOfType(java.lang.Class type, boolean includePrototypes, boolean includeFactoryBeans)
           
 java.lang.ClassLoader getClassLoader()
           
 java.lang.String getDisplayName()
           
 java.lang.String getId()
           
 java.lang.String getMessage(org.springframework.context.MessageSourceResolvable resolvable, java.util.Locale locale)
           
 java.lang.String getMessage(java.lang.String code, java.lang.Object[] args, java.util.Locale locale)
           
 java.lang.String getMessage(java.lang.String code, java.lang.Object[] args, java.lang.String defaultMessage, java.util.Locale locale)
           
 org.springframework.context.ApplicationContext getParent()
           
 org.springframework.beans.factory.BeanFactory getParentBeanFactory()
           
 java.lang.Object getProperty(java.lang.String name)
           
 org.springframework.core.io.Resource getResource(java.lang.String location)
           
 org.springframework.core.io.Resource[] getResources(java.lang.String locationPattern)
           
 javax.servlet.ServletContext getServletContext()
           
 long getStartupDate()
           
 java.lang.Class getType(java.lang.String name)
           
 boolean isPrototype(java.lang.String s)
           
 boolean isSingleton(java.lang.String name)
           
 boolean isTypeMatch(java.lang.String s, java.lang.Class aClass)
           
 void publishEvent(org.springframework.context.ApplicationEvent event)
           
 void registerIgnoredClassPathLocation(java.lang.String location)
          Registers a resource that should not be found on the classpath.
 void registerMockBean(java.lang.String name, java.lang.Object instance)
           
 void registerMockResource(java.lang.String location)
          Registers a mock resource.
 void registerMockResource(java.lang.String location, java.lang.String contents)
          Registers a mock resource.
 void unregisterIgnoredClassPathLocation(java.lang.String location)
          Unregisters a resource that should not be found on the classpath.
 void unregisterMockResource(java.lang.String location)
          Unregisters a mock resource.
 
Methods inherited from class groovy.lang.GroovyObjectSupport
getMetaClass, invokeMethod, setMetaClass, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

startupDate

java.util.Date startupDate

beans

java.util.Map beans

resources

java.util.List resources

ignoredClassLocations

java.util.List ignoredClassLocations

pathMatcher

org.springframework.util.PathMatcher pathMatcher
Constructor Detail

MockApplicationContext

public MockApplicationContext()
Method Detail

registerMockBean

public void registerMockBean(java.lang.String name,
                             java.lang.Object instance)

registerMockResource

public void registerMockResource(java.lang.String location)
Registers a mock resource. Path separator: "/"

Parameters:
location - the location of the resource. Example: /WEB-INF/grails-app/i18n/messages.properties

registerMockResource

public void registerMockResource(java.lang.String location,
                                 java.lang.String contents)
Registers a mock resource. Path separator: "/"

Parameters:
location - the location of the resource. Example: /WEB-INF/grails-app/i18n/messages.properties

unregisterMockResource

public void unregisterMockResource(java.lang.String location)
Unregisters a mock resource. Path separator: "/"

Parameters:
location - the location of the resource. Example: /WEB-INF/grails-app/i18n/messages.properties

registerIgnoredClassPathLocation

public void registerIgnoredClassPathLocation(java.lang.String location)
Registers a resource that should not be found on the classpath. Path separator: "/"

Parameters:
location - the location of the resource. Example: /WEB-INF/grails-app/i18n/messages.properties

unregisterIgnoredClassPathLocation

public void unregisterIgnoredClassPathLocation(java.lang.String location)
Unregisters a resource that should not be found on the classpath. Path separator: "/"

Parameters:
location - the location of the resource. Example: /WEB-INF/grails-app/i18n/messages.properties

getParent

public org.springframework.context.ApplicationContext getParent()
Specified by:
getParent in interface org.springframework.context.ApplicationContext

getId

public java.lang.String getId()
Specified by:
getId in interface org.springframework.context.ApplicationContext

getDisplayName

public java.lang.String getDisplayName()
Specified by:
getDisplayName in interface org.springframework.context.ApplicationContext

getStartupDate

public long getStartupDate()
Specified by:
getStartupDate in interface org.springframework.context.ApplicationContext

publishEvent

public void publishEvent(org.springframework.context.ApplicationEvent event)
Specified by:
publishEvent in interface org.springframework.context.ApplicationEventPublisher

containsBeanDefinition

public boolean containsBeanDefinition(java.lang.String beanName)
Specified by:
containsBeanDefinition in interface org.springframework.beans.factory.ListableBeanFactory

getBeanDefinitionCount

public int getBeanDefinitionCount()
Specified by:
getBeanDefinitionCount in interface org.springframework.beans.factory.ListableBeanFactory

getBeanDefinitionNames

public java.lang.String[] getBeanDefinitionNames()
Specified by:
getBeanDefinitionNames in interface org.springframework.beans.factory.ListableBeanFactory

getBeanDefinitionNames

public java.lang.String[] getBeanDefinitionNames(java.lang.Class type)

getBeanNamesForType

public java.lang.String[] getBeanNamesForType(java.lang.Class type)
Specified by:
getBeanNamesForType in interface org.springframework.beans.factory.ListableBeanFactory

getBeanNamesForType

public java.lang.String[] getBeanNamesForType(java.lang.Class type,
                                              boolean includePrototypes,
                                              boolean includeFactoryBeans)
Specified by:
getBeanNamesForType in interface org.springframework.beans.factory.ListableBeanFactory

getBeansOfType

public java.util.Map getBeansOfType(java.lang.Class type)
                             throws org.springframework.beans.BeansException
Specified by:
getBeansOfType in interface org.springframework.beans.factory.ListableBeanFactory
Throws:
org.springframework.beans.BeansException

getBeansOfType

public java.util.Map getBeansOfType(java.lang.Class type,
                                    boolean includePrototypes,
                                    boolean includeFactoryBeans)
                             throws org.springframework.beans.BeansException
Specified by:
getBeansOfType in interface org.springframework.beans.factory.ListableBeanFactory
Throws:
org.springframework.beans.BeansException

getBean

public java.lang.Object getBean(java.lang.String name)
                         throws org.springframework.beans.BeansException
Specified by:
getBean in interface org.springframework.beans.factory.BeanFactory
Throws:
org.springframework.beans.BeansException

getBean

public java.lang.Object getBean(java.lang.String name,
                                java.lang.Class requiredType)
                         throws org.springframework.beans.BeansException
Specified by:
getBean in interface org.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:
getBean in interface org.springframework.beans.factory.BeanFactory
Throws:
org.springframework.beans.BeansException

getProperty

public java.lang.Object getProperty(java.lang.String name)
Specified by:
getProperty in interface groovy.lang.GroovyObject
Overrides:
getProperty in class groovy.lang.GroovyObjectSupport

containsBean

public boolean containsBean(java.lang.String name)
Specified by:
containsBean in interface org.springframework.beans.factory.BeanFactory

isSingleton

public boolean isSingleton(java.lang.String name)
                    throws org.springframework.beans.factory.NoSuchBeanDefinitionException
Specified by:
isSingleton in interface org.springframework.beans.factory.BeanFactory
Throws:
org.springframework.beans.factory.NoSuchBeanDefinitionException

isPrototype

public boolean isPrototype(java.lang.String s)
                    throws org.springframework.beans.factory.NoSuchBeanDefinitionException
Specified by:
isPrototype in interface org.springframework.beans.factory.BeanFactory
Throws:
org.springframework.beans.factory.NoSuchBeanDefinitionException

isTypeMatch

public boolean isTypeMatch(java.lang.String s,
                           java.lang.Class aClass)
                    throws org.springframework.beans.factory.NoSuchBeanDefinitionException
Specified by:
isTypeMatch in interface org.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:
getType in interface org.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:
getAliases in interface org.springframework.beans.factory.BeanFactory
Throws:
org.springframework.beans.factory.NoSuchBeanDefinitionException

getParentBeanFactory

public org.springframework.beans.factory.BeanFactory getParentBeanFactory()
Specified by:
getParentBeanFactory in interface org.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:
getMessage in interface org.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:
getMessage in interface org.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:
getMessage in interface org.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:
getResources in interface org.springframework.core.io.support.ResourcePatternResolver
Throws:
java.io.IOException

getResource

public org.springframework.core.io.Resource getResource(java.lang.String location)
Specified by:
getResource in interface org.springframework.core.io.ResourceLoader

containsLocalBean

public boolean containsLocalBean(java.lang.String arg0)
Specified by:
containsLocalBean in interface org.springframework.beans.factory.HierarchicalBeanFactory

getAutowireCapableBeanFactory

public org.springframework.beans.factory.config.AutowireCapableBeanFactory getAutowireCapableBeanFactory()
                                                                                                  throws java.lang.IllegalStateException
Specified by:
getAutowireCapableBeanFactory in interface org.springframework.context.ApplicationContext
Throws:
java.lang.IllegalStateException

getClassLoader

public java.lang.ClassLoader getClassLoader()
Specified by:
getClassLoader in interface org.springframework.core.io.ResourceLoader

getServletContext

public javax.servlet.ServletContext getServletContext()
Specified by:
getServletContext in interface org.springframework.web.context.WebApplicationContext


Copyright (c) 2005-2006 The Grails project