On Tue, 2011-10-04 at 22:53 +0100, Mircea Markus wrote:
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)...
...
}
}
Unfortunately, this is not generally possible. The base class could be
there when using JUnit. However, when using TestNG with Arquillian, the
class needs to extend org.jboss.arquillian.testng.Arquillian. i.e.:
class TestClass extends Arquillian { ... }
(look at an example:
https://github.com/mgencur/infinispan-arquillian-container/commit/4fdfab2...)
This is due to TestNG itself (if does not allow Arquillian to modify
TestNG's behaviour via events to completely suit Arquillian's needs, so
Arq needs a base class that will help him with it - laicly said :-)
_______________________________________________
infinispan-dev mailing list
infinispan-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/infinispan-dev
--
Martin Gencur
--
JBoss QE, Enterprise Data Grid
Desk phone: +420 532 294 192, ext. 62192