You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by anemdhana <dh...@gmail.com> on 2014/12/10 09:53:40 UTC
Help - on using arquillian dbunit extension
Hi,
I am using arquillian dbunit extension to setup test data first before
running junit test methods.
Here is my arquillian.xml and junit. using the annotation @UsingDataSet not
really inserting any data in my database. Appreciate your help on this.
junit-
@RunWith(Arquillian.class)
@PersistenceTest
@Transactional(value = TransactionMode.COMMIT)
public class ItemRepositoryTest extends BaseTest {
@Deployment
public static Archive<?> createTestArchive() {
return createWebArchive();
}
@Inject
private AnemKartRepository<Item, String> itemRepository;
@Inject
private Logger log;
@Test
@UsingDataSet
// It is picking up -> //
/datasets/com.anem.anemkart.test.ItemRepositoryTest#testFindItemByCode.xml
public void testFindItemByCode() {
Item item = itemRepository.findById("108u6");
Assert.assertNotNull(item);
}
}
arquillian.xml-
<extension qualifier="persistence">
<property name="defaultDataSource">anemkartDS</property>
</extension>
<extension qualifier="persistence-dbunit">
<property name="excludeTablesFromCleanup">OPENJPASEQ</property>
<property name="filterTables">true</property>
</extension>
<container default="true" qualifier="tomee">
<configuration>
<property name="httpPort">-1</property>
<property name="stopPort">-1</property>
<property name="properties">
java.naming.factory.initial=org.apache.openejb.client.LocalInitialContextFactory
anemkartDS=new://Resource?type=DataSource
anemkartDS.JdbcDriver=org.apache.derby.jdbc.ClientDriver
anemkartDS.JdbcUrl=jdbc:derby://localhost:1527/anemkart;create=true
anemkartDS.UserName=APP
anemkartDS.Password=APP
anemkartDS.JtaManaged=true
</property>
</configuration>
</container>
--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Help-on-using-arquillian-dbunit-extension-tp4673192.html
Sent from the TomEE Users mailing list archive at Nabble.com.
Re: Help - on using arquillian dbunit extension
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi
Do you use tomee embedded or remote?
If embedded this is an arquillian-persistence limitation (see
http://rmannibucau.wordpress.com/2013/09/05/arquillian-persistence-and-embedded-container-openejbdbunithsqldb-case/)
Romain Manni-Bucau
@rmannibucau
http://www.tomitribe.com
http://rmannibucau.wordpress.com
https://github.com/rmannibucau
2014-12-10 9:53 GMT+01:00 anemdhana <dh...@gmail.com>:
> Hi,
> I am using arquillian dbunit extension to setup test data first before
> running junit test methods.
> Here is my arquillian.xml and junit. using the annotation @UsingDataSet not
> really inserting any data in my database. Appreciate your help on this.
>
> junit-
> @RunWith(Arquillian.class)
> @PersistenceTest
> @Transactional(value = TransactionMode.COMMIT)
> public class ItemRepositoryTest extends BaseTest {
>
> @Deployment
> public static Archive<?> createTestArchive() {
> return createWebArchive();
> }
>
> @Inject
> private AnemKartRepository<Item, String> itemRepository;
>
> @Inject
> private Logger log;
>
> @Test
> @UsingDataSet
> // It is picking up -> //
> /datasets/com.anem.anemkart.test.ItemRepositoryTest#testFindItemByCode.xml
> public void testFindItemByCode() {
> Item item = itemRepository.findById("108u6");
> Assert.assertNotNull(item);
> }
>
> }
>
> arquillian.xml-
>
> <extension qualifier="persistence">
> <property name="defaultDataSource">anemkartDS</property>
> </extension>
>
> <extension qualifier="persistence-dbunit">
> <property name="excludeTablesFromCleanup">OPENJPASEQ</property>
> <property name="filterTables">true</property>
> </extension>
>
> <container default="true" qualifier="tomee">
> <configuration>
> <property name="httpPort">-1</property>
> <property name="stopPort">-1</property>
> <property name="properties">
>
> java.naming.factory.initial=org.apache.openejb.client.LocalInitialContextFactory
>
> anemkartDS=new://Resource?type=DataSource
> anemkartDS.JdbcDriver=org.apache.derby.jdbc.ClientDriver
> anemkartDS.JdbcUrl=jdbc:derby://localhost:1527/anemkart;create=true
> anemkartDS.UserName=APP
> anemkartDS.Password=APP
> anemkartDS.JtaManaged=true
> </property>
> </configuration>
> </container>
>
>
>
> --
> View this message in context: http://tomee-openejb.979440.n4.nabble.com/Help-on-using-arquillian-dbunit-extension-tp4673192.html
> Sent from the TomEE Users mailing list archive at Nabble.com.