2 Replies Latest reply on Mar 14, 2013 2:40 AM by jobame

    How to access the DatabaseConnection for additional verifications in an arquillian test

    jobame

      Is there any possibility in an arquillian test to access the DatabaseConnection for additional verifications using dbunit - see example below? I am trying to verify e.g. the row count to make sure some entries have not been made into a table. Without @UsingDataSet and @ShouldMatchDataSet I can use dbunit but it would be nicer to have the expected data set be verified automatically and only some checks being made additionally.

       

      @RunWith(Arquillian.class)
      public class MyTest {
      
                static DatabaseConnection dbUnit;
      
                @Deployment
                public static WebArchive createDeployment() {
                     return DeploymentFactory.createDeployment();
                }
      
                @Inject
                ServiceBeanIf serviceBean;
      
                @Test
                @UsingDataSet("datainput.xml")
              @ShouldMatchDataSet("dataoutput.xml")
              public void testMethod() {
                     serviceBean.executeSomething();
                     dbUnit = SomeClass.getDatabaseConnection();
                     assertEquals(1, dbUnit.getRowCount("someTable"));
          }
      }