Package net.officefloor.spring.test
Class SpringRule
- java.lang.Object
-
- net.officefloor.spring.test.SpringRule
-
- All Implemented Interfaces:
org.junit.rules.TestRule
public class SpringRule extends java.lang.Object implements org.junit.rules.TestRule
Captures theConfigurableApplicationContext
fromSpringSupplierSource
.- Author:
- Daniel Sagenschneider
-
-
Constructor Summary
Constructors Constructor Description SpringRule()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.junit.runners.model.Statement
apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
org.springframework.context.ConfigurableApplicationContext
getApplicationContext()
Obtains theConfigurableApplicationContext
.<B> B
getBean(java.lang.Class<B> requiredType)
Obtains the Spring bean by type.java.lang.Object
getBean(java.lang.String name)
Obtains the Spring bean by name.
-
-
-
Method Detail
-
getApplicationContext
public org.springframework.context.ConfigurableApplicationContext getApplicationContext()
Obtains theConfigurableApplicationContext
.- Returns:
ConfigurableApplicationContext
.
-
getBean
public java.lang.Object getBean(java.lang.String name)
Obtains the Spring bean by name.- Parameters:
name
- Name of bean.- Returns:
- Bean.
-
getBean
public <B> B getBean(java.lang.Class<B> requiredType)
Obtains the Spring bean by type.- Parameters:
requiredType
- Required type.- Returns:
- Bean.
-
apply
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
- Specified by:
apply
in interfaceorg.junit.rules.TestRule
-
-