6 Replies Latest reply on Aug 24, 2015 11:35 AM by hoeppnerrobert

    Using Arquillian Persistence with Drone/Graphene

    btsaunde

      Has anyone been able to use Arquillian Persistence extension with Arquillian Graphene/Selenium in the same test? I have a project that is using the Persistence & Drone/Graphene extensions and separately they both work fine. I can configure the database for integration tests with Persistence, and I can do UI Acceptance tests with Drone.

       

      The problem is when I try to use the Persistence extension in a Drone test. For some reason the Persistence extension does not appear to execute as the database is never populated. Is there something special that needs to be done to enable the Persistence Extension to run in client mode with Arquillian?

       

      *Test Class*

      {code}

          @RunWith(Arquillian.class)

          @DataSource("java:jboss/datasources/ExampleDS")

          @UsingDataSet("OneUserAccount-Admin.yml")

          public class LoginIT {

       

              @Deployment(testable = false)

              public static WebArchive createDeployment() {

                  return DeploymentFactory.getTemplateDeployment();

              }

               ...

               @Test

               public void testLogin() {

                  this.openPage("login.xhtml");

       

                  final IdLocator userNameField = id("loginform:email");

                  final IdLocator passwordField = id("loginform:password");

                  final IdLocator loginButton = id("loginform:loginButton");

       

                  this.browser.type(userNameField, userName);

                  this.browser.type(passwordField, password);

                  waitForHttp(this.browser).click(loginButton);

       

                    //Test Fails Here b/c Validation fails due to the user not being loaded to the database

              }

               ...

          }

      {code}


      I have tried removing the deployment=false and using @RunAsClient with no luck. I have also tried placing the @UsingDataSet and the @ApplyScriptBefore annotation on the test itself with no luck.

       

       

        • 1. Re: Using Arquillian Persistence with Drone/Graphene
          bmajsak

          Hi Bryan,

           

          I think at this moment we unfortunately don't provide this feature yet. Would you mind to open feature request in JIRA so I can investigate on that (+ you will see the progress).

           

          Many thanks!

          Bartosz

          • 2. Re: Using Arquillian Persistence with Drone/Graphene
            btsaunde

            Bartosz, I created Feature Request ARQ-1077 for you to investigate.

            • 3. Re: Re: Using Arquillian Persistence with Drone/Graphene
              jgurda

              Bartosz,

               

              does this limitation also apply to "@RunAsClient" mode?

               

              I have following class testing JaxRS resource (EjbTestBase simply creates WAR file):

              @RunAsClient
              @RunWith(Arquillian.class)
              @UsingDataSet({ "datasets/ApplicationConfigurationWithEmbededMongoDb.xls"})
              public class TestJaxRsResource extends EjbTestBase {
              
                  @ArquillianResource
                  private URL deploymentURL;
              
                  @Test
                  public void jaxRsClientTest() throws Exception {
                        //JAXRS client code here. It uses data populated in @UsingDataSet anotation
                   }
                      Assert.assertEquals(200L, response.getStatus());
                  }
              

               

              Unfortunately database is not populated with sample data. I set dbunit log level to DEBUG so I would see inserts in JBoss logs but there are no iserts at all.

               

              Thanks,

              Jan

              • 4. Re: Re: Using Arquillian Persistence with Drone/Graphene
                bmajsak

                Hi Jan,

                 

                unfortunately you are also in the same situation. For the time being you can use this not so great workaround mentioned in JIRA I will look at how we can leverage WARP for that.

                 

                Will keep you posted.

                 

                Cheers,

                Bartosz

                • 5. Re: Re: Re: Using Arquillian Persistence with Drone/Graphene
                  jgurda

                  Thank you! Workaround works perfectly.

                   

                  Attaching skeleton of my test:

                   

                  @RunWith(Arquillian.class)
                  @Cleanup(phase = TestExecutionPhase.NONE)
                  public class TestJaxRsResource {
                  
                      @Before
                      public void setUp() throws Exception {
                          // Init code
                      }
                  
                      @After
                      public void tearDown() throws Exception {
                          // tear down code
                      }
                  
                      @Test
                      @InSequence(1)
                      @UsingDataSet({ "datasets/ApplicationConfigurationWithEmbededMongoDb.xls", "datasets/device/SampleDevices.xls" })
                      public void populateDatabaseWorkaround() {
                          // Populates database since unable to use @UsingDataSet with @RunAsClient
                          // Check https://issues.jboss.org/browse/ARQ-1077
                      }
                  
                      @Test
                      @RunAsClient
                      @InSequence(2)
                      public void shouldAddLocation(@ArquillianResource URL deploymentURL) throws Exception {
                      // deploymentURL - resource injected by Arquillian - holds URL to deployed WAR 
                  
                      // Client side test code goes here....
                          // given
                          // when
                      // then
                      }
                  

                   

                  Regards,

                  Jan

                  • 6. Re: Using Arquillian Persistence with Drone/Graphene
                    hoeppnerrobert

                    Hello Jan,

                    If I do so, then I have to ad the test to the deployment.

                    And then Arquillian needs all dependend Classes in Deployment.

                     

                    Can you show your deployment, please?