1 Reply Latest reply: Apr 23, 2012 7:47 AM by Bartosz Majsak RSS

Arquillian Persistence alpha4: Naming of @DataSource

Craig Ringer Newbie

I'm currently writing a test with Arquillian Persistence ext alpha4, and found myself wondering if @DataSource is really the best name for the annotation specifying the data source for arquillian-persistence cleanups/population.

 

@DataSource is a very generic name. Sure, it's scoped to org.​jboss.​arquillian.​persistence.DataSource, but most people will use an import, so classes will just look like:

 

@RunWith(Arquillian.class)
@DataSource("java:/datasources/some-test-ds")
public class SomeTest {
   //....
}

 

This is particularly confusing if @DataSource isn't the same as the data source being used by the injected EntityManager for the persistence unit. In my case, for example, I need DBUnit and arquillian persistence to be operating with greater database priveleges than the tested class, so I'm using a different datasource. I do the same in another test where I'm testing very strict requirements for when certain changes become visible to other transactions in the database.

 

Maybe before the API goes final it's worth looking at possible alternative names for this annotation? ArquillianDataSource? TestDataSource?

 

On the upside, naming aside, it's really handy being able to get a different DataSource to do cleanup/setup work with, to run SQL scripts so easily, and to load/compare datasets. I'm really impressed, and appreciate that this has been released for us all to use.

 

Opinions?