[infinispan-dev] ISPN-ARQUILLIAN - embedded mode
Martin Gencur
mgencur at redhat.com
Wed Oct 5 03:57:09 EDT 2011
On Wed, 2011-10-05 at 09:43 +0200, Martin Gencur wrote:
> 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/4fdfab2273e30e0592fb308f3407c9d40e3a8419#diff-7)
>
> 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 :-)
>
Well, I could possibly extend Arquillian by another class T an let my
test class extend this T class. There is another problem, though. The
DatagridManager class already contains such shortcuts methods and I
committed this class into infinispan-core for maintainability reasons.
Utility classes that this class is using are changing quite often. If I
wrote such helper class with shortcut methods in ispn-arq-container, I
would need to maintain it manually (when anything changes in
infinispan-core).
>
> >
> >
> >
> >
> > _______________________________________________
> > infinispan-dev mailing list
> > infinispan-dev at 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
More information about the infinispan-dev
mailing list