0 Replies Latest reply on Dec 10, 2014 4:22 AM by Dhana kumar

    Help - on using arquillian dbunit extension

    Dhana kumar Newbie

      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>