public abstract class ContainerTest extends Object implements TestRunnerFacade.ContextAware, TestRunnerFacade.Initializable
Note that any JUnit related features like @Before, @After and so on will run in the client JVM and not on the server.
You can, however, override the doInit method to perform initialization tasks and use the serviceLocator to perform CDI and JNDI lookups in the container.
Note that the container will have to provide an EntityManager producer so we can inject it into our test class.
Parameterized tests are not supported.
| Modifier and Type | Field and Description |
|---|---|
protected org.jboss.logging.Logger |
_log |
protected javax.persistence.EntityManager |
em
EntityManager provided by the container.
|
protected ch.inftec.ju.db.JuEmUtil |
emUtil
JuEmUtil instance wrapped around the EntityManager.
|
protected ServiceLocator |
serviceLocator
ServiceLocator instance that can be used to lookup JNDI or CDI objects on the server.
|
ContainerTestRunnerRule |
testRunnerRule
Rule that runs the method statements on the remote JBoss container VM
|
| Constructor and Description |
|---|
ContainerTest() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
doInit()
Extending classes can override this method to perform custom initialization.
|
protected Path |
getLocalPath(Path relativePath,
boolean createParentDirectories)
Gets a Path instance relative to the 'local' test (rather than the JBoss server context).
|
protected Path |
getLocalPath(String relativePath,
boolean createParentDirectories)
Gets a Path instance relative to the 'local' test (rather than the JBoss server context).
|
void |
init()
Initializer method that is called before the unit test is executed.
|
void |
setContext(TestRunnerFacade.TestRunnerContext context)
Sets the TestRunnerContext
|
protected org.jboss.logging.Logger _log
public ContainerTestRunnerRule testRunnerRule
protected javax.persistence.EntityManager em
protected ch.inftec.ju.db.JuEmUtil emUtil
protected ServiceLocator serviceLocator
Note that the ServiceLocator is not configured to lookup remote objects
public final void setContext(TestRunnerFacade.TestRunnerContext context)
TestRunnerFacade.ContextAwaresetContext in interface TestRunnerFacade.ContextAwarepublic final void init()
TestRunnerFacade.InitializableThe method will be called within the same EJB / transaction context as the test method
init in interface TestRunnerFacade.Initializableprotected void doInit()
protected final Path getLocalPath(String relativePath, boolean createParentDirectories)
relativePath - Relative path like target/file.xmlcreateParentDirectories - If true, the parent directories of the path are created if necessaryprotected final Path getLocalPath(Path relativePath, boolean createParentDirectories)
relativePath - Relative path like target/file.xmlcreateParentDirectories - If true, the parent directories of the path are created if necessaryCopyright © 2014. All rights reserved.