On 22 Sep 2011, at 14:45, Martin Gencur wrote:
Hi,
I'm currently implementing support for testing of embedded caches in
https://github.com/mgencur/infinispan-arquillian-container project and
would like to discuss future steps.
As mentioned in
http://community.jboss.org/message/551784, the tests
should look like this:
@RunWith(Arquillian.class)
class TestClass {
@InfinispanResource
DatagridManager datagridManager;
@Before
void setup() {
CacheContainer cm1 = ...
CacheContainer cm2 = ...
datagridManager.registerCacheManager(cm1, cm2);
}
@Test
void testMethod() {
datagridManager.cache(index).put(xx)
datagridManager.manager(index).getStatus()
datagridManager.tm(cache)...
...
}
}//TestClass
Nice
You might also want to create a base class:
AbstractTest {
@InfinispanResource
DatagridManager dm;
//some shortcut methods
public Cache cache(int index) {
return dm.cache(index);
}
public TransactionManager tm(int index) {
return dm.manager(index);
}
//...other
}
then your test class would be simpler to write and read:
@RunWith(Arquillian.class)
class TestClass extends AbstractTest {
@Test
void testMethod() {
cache(index).put(xx)
manager(index).getStatus()
tm(cache)...
...
}
}