Package org.apache.struts2.mock
Class MockContainer
java.lang.Object
org.apache.struts2.mock.MockContainer
- All Implemented Interfaces:
Serializable,Container
Mock implementation to be used in unittests
- See Also:
-
Field Summary
Fields inherited from interface org.apache.struts2.inject.Container
DEFAULT_NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> TgetInstance(Class<T> type) Convenience method. Equivalent togetInstance(type, DEFAULT_NAME).<T> TgetInstance(Class<T> type, String name) Gets an instance of the given dependency which was declared inContainerBuilder.getInstanceNames(Class<?> type) Gets a set of all registered names for the given type<T> TCreates and injects a new instance of typeimplementation.voidInjects dependencies into the fields and methods of an existing object.voidRemoves the scope strategy for the current thread.voidsetScopeStrategy(Scope.Strategy scopeStrategy) Sets the scope strategy for the current thread.
-
Constructor Details
-
MockContainer
public MockContainer()
-
-
Method Details
-
inject
Description copied from interface:ContainerInjects dependencies into the fields and methods of an existing object. -
inject
Description copied from interface:ContainerCreates and injects a new instance of typeimplementation. -
getInstance
Description copied from interface:ContainerGets an instance of the given dependency which was declared inContainerBuilder.- Specified by:
getInstancein interfaceContainer- Type Parameters:
T- type- Parameters:
type- of dependencyname- of dependency- Returns:
- instance
-
getInstance
Description copied from interface:ContainerConvenience method. Equivalent togetInstance(type, DEFAULT_NAME).- Specified by:
getInstancein interfaceContainer- Type Parameters:
T- type- Parameters:
type- of dependency- Returns:
- instance
-
getInstanceNames
Description copied from interface:ContainerGets a set of all registered names for the given type- Specified by:
getInstanceNamesin interfaceContainer- Parameters:
type- The instance type- Returns:
- A set of registered names or empty set if no instances are registered for that type
-
setScopeStrategy
Description copied from interface:ContainerSets the scope strategy for the current thread.- Specified by:
setScopeStrategyin interfaceContainer- Parameters:
scopeStrategy- scope strategy
-
removeScopeStrategy
public void removeScopeStrategy()Description copied from interface:ContainerRemoves the scope strategy for the current thread.- Specified by:
removeScopeStrategyin interfaceContainer
-