0

I am just getting started with Arquillian Warp and seems to have hit a stumbling block.

I have a basic UI Test for a registration page

@WarpTest
@RunWith(Arquillian.class)
public class TestProfileEdit extends AbstractUsersTest {

@Drone
FirefoxDriver browser;

@Page
EditProfilePage editProfilePage;

@Page
LoginPage loginPage;

@ArquillianResource
private URL baseURL;

@Deployment
public static Archive<?> createLoginDeployment() throws IOException {
      // trimmed for brevity
}

@Before
public void setup() throws MalformedURLException{

    final URL loginURL = new URL(baseURL, "login.jsf");
    browser.navigate().to(loginURL);
    loginPage.login("test@domain.com", "password");

    final URL pageURL = new URL(baseURL, "profile/edit.jsf");
    System.out.println(pageURL.toExternalForm());
    browser.navigate().to(pageURL);

}

@After
public void tearDown() {
    browser.manage().deleteAllCookies();
}

@Test
@RunAsClient
public void testSaveData() {

    editProfilePage.getDialog().setFirstName("Test First Name");

    Warp.execute(new ClientAction() {

        @Override
        public void action() {
            editProfilePage.getDialog().save();
        }
    }).verify(new TestProfileOnServer());

}


@SuppressWarnings("serial")
public static class TestProfileOnServer extends ServerAssertion {

    @Inject
    private EntityManager em;

    @Inject
    private Identity identity;

    @Inject
    Credentials credentials;

    @AfterPhase(Phase.RENDER_RESPONSE)
    public void testSavedUserProfile()  {


        System.out.println("RUNNING TEST");

        String username = identity.getUser().getId();

        TypedQuery<UserProfile> q = em.createQuery(
                "SELECT u from UserProfile u where u.userIdentity.name like :username", UserProfile.class);

        UserProfile p;
        p = q.setParameter("username", username).getSingleResult();

        assertEquals("Test First Name", p.getFirstName());
    }

}

}

I have tried the various combinations on testSavedUserProfile() method with absolutely no luck in getting that to trigger.

The test always ends with

java.lang.IllegalStateException: java.util.concurrent.ExecutionException: org.jboss.arquillian.warp.client.execution.AssertionHolder$ServerResponseTimeoutException

I can see the page getting posted and redirected correctly on the firefox window that gets opened up. I tried to get it to not redirect etc. and nothing has helped.

I feel like I am missing something basic and simple but no idea what!

Any help much appreciated.

Thanks.

drone.ah
  • 1,135
  • 14
  • 28

1 Answers1

1

I've recently encountered a similar problem with Arquillian Warp.

One of the reasons my code didn't get called was that Arquillian merges the server-sde servlet filter into a web archive (WAR) deplyoment only. Neither EAR nor JAR deployments work off the shelf.

For my concrete problem (EAR deployment) I modified the test classes in a way that I merge in the Arquillian filter myself when assembling the tested WAR which in turn is packed into an EAR deployment.

The other problem I ran across was that the AfterServlet event is simply not fired within the unit test execution scope but as part of the servlet filter cleanup code. I believe this logic is totally broken and I build a private fork of the servlet filter which IMHO is handling the logic correctly.

rbieniek
  • 11
  • 1