public class TestContainer
extends org.junit.rules.ExternalResource
implements org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.AfterAllCallback
It's recommended to use TestContainer with TestUiEnvironment, but you can also use it directly as
shown below.
Usage of the common instance (time saving):
@RegisterExtension
public static TestContainer cont = TestContainer.Common.INSTANCE;
@Test
public void testSomething() {
}
Usage of a specific instance:
@RegisterExtension
public static TestContainer cont = new TestContainer()
.setAppPropertiesFiles(Arrays.asList(
"com/haulmont/cuba/web-app.properties",
"com/haulmont/cuba/web/testsupport/test-web-app.properties",
"com/company/sample/web/my-test-app.properties"));
@Test
public void testSomething() {
}
| Modifier and Type | Class and Description |
|---|---|
static class |
TestContainer.Common |
| Modifier and Type | Field and Description |
|---|---|
protected java.util.List<java.lang.String> |
appComponents |
protected java.util.List<java.lang.String> |
appPropertiesFiles |
protected java.lang.String |
springConfig |
| Constructor and Description |
|---|
TestContainer() |
| Modifier and Type | Method and Description |
|---|---|
TestContainer |
addAppPropertiesFile(java.lang.String name) |
protected void |
after() |
void |
afterAll(org.junit.jupiter.api.extension.ExtensionContext extensionContext) |
protected void |
before() |
void |
beforeAll(org.junit.jupiter.api.extension.ExtensionContext extensionContext) |
protected void |
cleanupContext() |
java.util.List<java.lang.String> |
getAppComponents() |
org.springframework.context.support.ClassPathXmlApplicationContext |
getApplicationContext() |
java.util.Map<java.lang.String,java.lang.String> |
getAppProperties() |
java.util.List<java.lang.String> |
getAppPropertiesFiles() |
<T> T |
getBean(java.lang.Class<T> beanType) |
<T> T |
getBean(java.lang.String name) |
<T> T |
getBean(java.lang.String name,
java.lang.Object... args) |
<E extends Entity> |
getEntityFactory(java.lang.Class<E> entityClass,
TestEntityState entityState)
Returns factory for creating entity instances for tests.
|
protected java.lang.String |
getLogbackConfigLocation() |
java.lang.String |
getSpringConfig() |
protected void |
initAppComponents() |
protected void |
initAppContext() |
protected void |
initAppProperties() |
TestContainer |
setAppComponents(java.util.List<java.lang.String> appComponents) |
TestContainer |
setAppPropertiesFiles(java.util.List<java.lang.String> appPropertiesFiles) |
TestContainer |
setSpringConfig(java.lang.String springConfig) |
protected void |
setupContext() |
void |
setupLogging(java.lang.String logger,
ch.qos.logback.classic.Level level) |
protected java.lang.String springConfig
protected java.util.List<java.lang.String> appComponents
protected java.util.List<java.lang.String> appPropertiesFiles
protected java.lang.String getLogbackConfigLocation()
public void setupLogging(java.lang.String logger,
ch.qos.logback.classic.Level level)
public java.util.List<java.lang.String> getAppComponents()
public java.util.List<java.lang.String> getAppPropertiesFiles()
public java.lang.String getSpringConfig()
public TestContainer setSpringConfig(java.lang.String springConfig)
public TestContainer setAppComponents(java.util.List<java.lang.String> appComponents)
public TestContainer setAppPropertiesFiles(java.util.List<java.lang.String> appPropertiesFiles)
public TestContainer addAppPropertiesFile(java.lang.String name)
public org.springframework.context.support.ClassPathXmlApplicationContext getApplicationContext()
public java.util.Map<java.lang.String,java.lang.String> getAppProperties()
public <T> T getBean(java.lang.Class<T> beanType)
public <T> T getBean(java.lang.String name)
public <T> T getBean(java.lang.String name,
java.lang.Object... args)
public void afterAll(org.junit.jupiter.api.extension.ExtensionContext extensionContext)
throws java.lang.Exception
afterAll in interface org.junit.jupiter.api.extension.AfterAllCallbackjava.lang.Exceptionpublic void beforeAll(org.junit.jupiter.api.extension.ExtensionContext extensionContext)
throws java.lang.Exception
beforeAll in interface org.junit.jupiter.api.extension.BeforeAllCallbackjava.lang.Exceptionprotected void before()
throws java.lang.Throwable
before in class org.junit.rules.ExternalResourcejava.lang.Throwableprotected void after()
after in class org.junit.rules.ExternalResourceprotected void initAppComponents()
protected void initAppProperties()
protected void initAppContext()
protected void cleanupContext()
protected void setupContext()
public <E extends Entity> TestEntityFactory<E> getEntityFactory(java.lang.Class<E> entityClass, TestEntityState entityState)
entityClass - entities of this class will be created by the factoryentityState - entities with this state will be created by the factory