@Inherited @Documented @Target(value={TYPE,METHOD}) @Retention(value=RUNTIME) public @interface JpaCacheEviction
Necessary attribute which must be set in annotation or in configuration is JNDI name(s) of entity manager(s), other attributes have default values. Default phase is before test method invocation and is used strategy which evict all entities from cache. Default values can be changed in Arquillian descriptor.
Eviction can be defined on test class or test method level, where latter takes precedence if both are present.
Example configuration:
<extension qualifier="persistence-jpacacheeviction">
<property name="defaultPhase">AFTER</property>
<property name="defaultEntityManager">java:comp/env/MyPersistenceUnit</property>
<property name="defaultStrategy">com.mycompany.MyCustomJpaCacheEvictionStrategy</property>
</extension>
Example test:
@RunWith(Arquillian.class)
@JpaCacheEviction(entityManager = "java:comp/env/MyPersistenceUnit")
public class MyIntegrationTest {
...
Cache| Modifier and Type | Optional Element and Description |
|---|---|
String[] |
entityManager
Defines JNDI names of entity managers which second level caches should be evicted
during test execution.
|
TestExecutionPhase |
phase
Defines when during the test execution second level cache should be evicted.
|
Class<? extends JpaCacheEvictionStrategy> |
strategy
Defines strategy how to evict cache.
|
public abstract TestExecutionPhase phase
public abstract String[] entityManager
public abstract Class<? extends JpaCacheEvictionStrategy> strategy
Copyright © 2018 JBoss by Red Hat. All rights reserved.