Arquillian Warp 1.0.0.Alpha1 Released

Since we wrote this post we didn't laze around. Check our latest announcement.

The Arquillian team is proud to announce the 1.0.0.Alpha1 release of the Arquillian Warp component!

  • Have you ever wanted to test a web application using real HTTP requests, but still have the opportunity to verify server-side state and behavior?
  • Wouldn’t it be great to have the full power of Arquillian Drone, driving Selenium or WebDriver on the client, then combine that with an Arquillian in-container test?

Now you can!

Ike’s innovative army has created yet another powerful weapon for your testing arsenal, Arquillian Warp.

Testing on both sides of the request

Arquillian Warp fills the void between client-side and server-side testing. Using Warp, you can initiate an HTTP request using a client-side testing tool such as WebDriver and, in the same request cycle, execute in-container server-side tests. This powerful combination lets you cover integration across client and server.

Now you can send real requests that execute real application logic and render content in a real browser and test it end-to-end. Mocks? Who needs those? Imagine the debugging possibilities this opens up!

This may sound like sci-fi, but it’s a reality. It’s advanced alien technology for killing real bugs that you can get your hands on today!

Let’s warp to the code

We’ll start with a normal Arquillian Drone client-side test with one enhancement, a @WarpTest annotation on the test class. This extra annotation instructs Arquillian Warp to enhance the request.

@WarpTest
@RunWith(Arquillian.class)
public class BasicWarpTest {
    @Drone
    WebDriver browser;

    @ArquillianResource
    URL contextPath;

    @Deployment
    public static WebArchive createDeployment() { ... }

    @Test
    @RunAsClient
    public void test_initial_page() {
        // triggers a HTTP request to a server
        browser.navigate().to(contextPath);
        // stay tuned...
    }
}

Note that you can use any HTTP client. For the sake of simplicity we’ve used @Drone to hook WebDriver (Selenium 2) into our test. Additionally, we’ve declared a web archive to be tested and injected its URL into the test case.

So far, we’ve defined a basic Drone test. Let’s start to warp this test so we can use it to test server-side logic as well. We begin by defining an implementation of ServerAssertion as an inner class of the test:

public static class InitialRequestAssertion extends ServerAssertion {
    @Inject
    TowelBean towel;

    @AfterPhase(RENDER_RESPONSE)
    public void test_initial_state() {
        // verify we are on right viewId
        assertEquals("/index.xhtml", FacesContext.getCurrentInstance().getViewRoot().getViewId());

        // assert the bean state
        assertNull(42, towelBean.getAnswerToLife());
    }
}

An object of this assertion class will be later enriched on the server (i.e., TowelBean will be injected) and then the lifecycle method annotated with @AfterPhase will be invoked in an appropriate phase of the request (after the response is rendered in the JSF lifecycle). This lifecycle method is effectively our server-side test.

All we need to do now is hook this assertion class to the request that is initiated by the browser. To do that, we warp the Selenium call in a Warp action:

@Test
@RunAsClient
public void test_initial_page() {
    // define the client action which will lead to HTTP request
    Warp.execute(new ClientAction() {
        public void action() {
            // the original request
            browser.navigate().to(contextPath);
        }
    
    // enhance the subsequent HTTP request with ServerAssertion
    }).verify(new InitialRequestAssertion());
}

That’s it! Here’s how it plays out:

  1. The Selenium-controlled browser initiates an HTTP request
  2. The request is trapped and enhanced with the InitialRequestAssertion object (which gets added as a payload of the request)
  3. When the request arrives at the server, the InitialRequestAssertion assertion object is registered with Arquillian and the request lifecycle proceeds
  4. After the response is rendered on the server, the InitialRequestAssertion object is enriched with all the required resources (EJB beans, CDI beans, Spring beans or Arquillian resources) and the lifecycle (test) method is invoked
  5. Once the request is complete, the InitialRequestAssertion object is sent back to the client
  6. If anything on the server-side failed (including assertions you defined), the failure is propagated back to the client and handled as a test failure

Currently, Warp supports lifecycle callbacks for the Servlet and JSF lifecycles, but it’s designed to be able to handle any server-side lifecycle.

Some of the highlights in this release

Support for Servlet events

Warp gives you the ability to test any Servlet lifecycle with these two lifecycle annotations:

@BeforeServlet – triggered before the request is processed by the Servlet
@AfterServlet – triggered after the request is processed by the Servlet

Support for JSF lifecycle events (Phaser extension)

Warp’s Phaser extension provides integration with the JSF lifecycle. You can use these lifecycle annotations to test the application in any JSF phase:

@BeforePhase(Phase) – triggered before the given JSF phase is executed
@AfterPhase(Phase) – triggered after the given JSF phase is executed

Compatible with any HTTP client

Warp works with any HTTP client: Selenium, HtmlUnit, HttpUnit, REST client, JavaScript test, Android device. No boundaries here!

Open to more protocols

Only the HTTP protocol is supported currently, but other protocols can be supported as well! (An SPI will be defined in a later releases)

Open to more frameworks

Warp is designed to support any server-side web framework based on the Servlets API

Need to know more?

You can find the complete Maven-based sample usage in the Arquillian Showcase.

Additionally, you can look at the functional tests in the Warp test suite:

Roadmap

In future releases, we’ll be looking into further improving the extension, most notably by providing framework-specific enrichments:

  • Injectable HttpServletRequest
  • Injectable FacesContext
  • etc.

Warp offers many possibilities for integration:

  • Support for wide range of server-side web frameworks (Wicket, Vaadin, GWT, Tapestry, …)
  • Support for alternative protocols (WebSockets)
  • Built-in support for variety of client-side testing tools

Call to action

If you would like to have support for your favorite web framework, you see features that are missing or you can see room for improvement, don’t hesitate and come to the Arquillian forums or the #arquillian channel on Freenode IRC!

We would love to hear your ideas and feedback for how to stretch Warp to reach beyond the boundaries of the test galaxy!

What is Arquillian?

Arquillian is open source software that empowers you to test JVM-based applications more effectively. Created to defend the software galaxy from bugs, Arquillian brings your test to the runtime so you can focus on testing your application's behavior rather than managing the runtime. Using Arquillian, you can develop a comprehensive suite of tests from the convenience of your IDE and run them in any IDE, build tool or continuous integration environment.

Release details

Component Arquillian Warp
Version 1.0.0.Alpha1 view tag
Release date 2012-05-24
Released by Lukas Fryc
Compiled against

Published artifacts org.jboss.arquillian.extension

  • org.jboss.arquillian.extension » arquillian-warp-bom pom
  • org.jboss.arquillian.extension » arquillian-warp-api jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-warp-spi jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-warp-impl jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-warp-phaser jar javadoc pom

Release notes and resolved issues 9

First Release of Warp Extension

Enhancement
  • ARQ-931 - Warp: Define API/SPI
  • ARQ-933 - Warp: server exception propagation
  • ARQ-948 - Make the ServerAssertion abstract class to ensure future compatibility
  • ARQ-955 - Warp: Define BOM
Feature Request
  • ARQ-578 - Create a Extension for handling Server State assertion during normal Servlet/JSF requests
  • ARQ-957 - Add Warp Showcase sample
Bug
  • ARQ-935 - Should handle de-enrich of final fields
  • ARQ-943 - Should be able to detect Serialization problems

Thanks to the following list of contributors: Lukas Fryc, Ken Finnigan, Aslak Knutsen

Graphene 2.0.0.Alpha1 Released

Since we wrote this post we didn't laze around. Check our latest announcement.

The Arquillian team is proud to announce the 2.0.0.Alpha1 release of the Graphene component!

What is Arquillian?

Arquillian is open source software that empowers you to test JVM-based applications more effectively. Created to defend the software galaxy from bugs, Arquillian brings your test to the runtime so you can focus on testing your application's behavior rather than managing the runtime. Using Arquillian, you can develop a comprehensive suite of tests from the convenience of your IDE and run them in any IDE, build tool or continuous integration environment.

Release details

Component Graphene
Version 2.0.0.Alpha1 view tag
Release date 2012-05-24
Released by Lukas Fryc
Compiled against

Published artifacts org.jboss.arquillian.graphene

  • org.jboss.arquillian.graphene » graphene-parent pom
  • org.jboss.arquillian.graphene » graphene-selenium-parent pom
  • org.jboss.arquillian.graphene » graphene-selenium-api jar javadoc pom
  • org.jboss.arquillian.graphene » graphene-selenium-impl jar javadoc pom
  • org.jboss.arquillian.graphene » graphene-selenium-drone jar javadoc pom
  • org.jboss.arquillian.graphene » graphene-selenium pom
  • org.jboss.arquillian.graphene » graphene-webdriver-parent pom
  • org.jboss.arquillian.graphene » graphene-webdriver-impl jar javadoc pom
  • org.jboss.arquillian.graphene » graphene-webdriver-drone jar javadoc pom
  • org.jboss.arquillian.graphene » graphene-webdriver pom
  • org.jboss.arquillian.graphene » arquillian-graphene pom

Release notes and resolved issues 3

Thread-local context support

Enhancement
  • ARQGRA-136 - Replace mockito dependency with cglib
Feature Request
  • ARQGRA-56 - Support Thread-Local Context with Selenium 2

Thanks to the following list of contributors: Lukas Fryc

Arquillian Spring Framework Extension 1.0.0.Alpha1 Released

Since we wrote this post we didn't laze around. Check our latest announcement.

The Arquillian team is proud to announce the 1.0.0.Alpha1 release of the Arquillian Spring Framework Extension component!

We’re moving the boundaries of Arquillian into a completely new area by including built-in support for testing applications that use the Spring Framework. This release is the first milestone for this extension. The focus so far has been on providing support for Spring’s core features (e.g., IoC container, data sources, persistence, transactions, javax.inject and EJB integration, etc.).

I’m working on the Spring extension for my Google Summer of Code 2012 project. This post also serves as my first status update. Coding began yesterday, but I’ve already been hard at work ;)

Some of the highlights in this release

Dependency injection

The extension provides three simple ways to enable Spring support in Arquillian test case. In other to create application context from XML simply add to the test @SpringConfiguration with locations of the XML files. Java-based config is supported as well with @SpringAnnotatedConfiguration which can be configured with concrete classes or names of packages to scan. The last possibility, @SpringWebConfiguration that allows to retrieve the application context of the specific DispatcherServlet running in the container, can be used only with web applications.

Custom context classes

There are situations when plain Spring context isn’t enough, so we allowed to register custom context classes that will be instantiated for each test. The context classes could be customized through annotations or through extension settings provided with arquillian.xml. A typical scenario would be for example running the Spring in JBoss AS using Snowdrop custom context classes.

Artifact packaging

The extension, by default, handles packaging of spring-context and spring-web automatically with each test.

Intuitive configuration

The extension can be easily configured through the arquillian.xml. All the settings like e.g. artifacts versions can be overridden here.

arquillian.xml
<extension qualifier="spring">
    <property name="autoPackage">true</property>
    <property name="springVersion">3.0.0.RELEASE</property>
    <property name="cglibVersion">2.2</property>

    <property name="includeSnowdrop">true</property>
    <property name="snowdropVersion">2.0.3.Final</property>

<property name=“customContextClass”>org.jboss.spring.vfs.context.VFSClassPathXmlApplicationContext</property>
</extension>

Here’s an example of a basic Spring test with Arquillian:

DefaultStockRepositoryTestCase.java
@RunWith(Arquillian.class)
@SpringConfiguration("applicationContext.xml")
public class DefaultStockRepositoryTestCase {

    @Deployment
    public static JavaArchive createTestArchive() {
        return ShrinkWrap.create(JavaArchive.class)
                .addClasses(Stock.class, StockRepository.class, StockService.class,
                        DefaultStockRepository.class, DefaultStockService.class)
                .addAsResource("applicationContext.xml");
    }

    @Autowired
    StockRepository stockRepository;

    @Test
    public void testSave() {
        Stock acme = createStock("Acme", "ACM", 123.21D, new Date());
        Stock redhat = createStock("Red Hat", "RHC", 59.61D, new Date());

        stockRepository.save(acme);
        stockRepository.save(redhat);

        assertTrue("The stock id hasn't been assigned.", acme.getId() > 0);
        assertTrue("The stock id hasn't been assigned.", redhat.getId() > 0);
    }
}

For more examples on how to use these extensions and quickly get started with development you can take a look at prepared showcase. Additionally, you can browse the integration tests that are part of project source code.

For help with preparing this release, I’d like to especially thank Dan Allen, Marius Bogoevici and Aslak Knutsen for sharing their knowledge and providing helping hand.

We look forward to hearing your feedback about this release in the community forums!

What is Arquillian?

Arquillian is open source software that empowers you to test JVM-based applications more effectively. Created to defend the software galaxy from bugs, Arquillian brings your test to the runtime so you can focus on testing your application's behavior rather than managing the runtime. Using Arquillian, you can develop a comprehensive suite of tests from the convenience of your IDE and run them in any IDE, build tool or continuous integration environment.

Release details

Component Arquillian Spring Framework Extension
Version 1.0.0.Alpha1 view tag
Release date 2012-05-21
Released by Aslak Knutsen
Compiled against

Published artifacts org.jboss.arquillian.extension

  • org.jboss.arquillian.extension » arquillian-service-deployer-spring-common jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-service-deployer-spring-2.5 jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-service-deployer-spring-2.5-int-tests jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-service-deployer-spring-3 jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-service-deployer-spring-3-int-tests jar javadoc pom

Release notes and resolved issues 2

Support for Spring enrichment in other Containers

Feature Request
  • ARQ-301 - Create a Spring framework integration (for non-standalone containers)

Thanks to the following list of contributors: Jakub Narloch, Aslak Knutsen

ShrinkWrap 1.1.0-alpha-2 Released

Since we wrote this post we didn't laze around. Check our latest announcement.

The Arquillian team is proud to announce the 1.1.0-alpha-2 release of the ShrinkWrap component!

What is ShrinkWrap?

ShrinkWrap is the simplest way to create archives in Java. Using the fluent and intuitive ShrinkWrap API, developers may assemble JARs, WARs, and EARs to be deployed directly by Arquillian during testing.

Release details

Component ShrinkWrap
Version 1.1.0-alpha-2 view tag
Release date 2012-05-10
Released by Andrew Lee Rubinger
Compiled against
  • JUnit – 4.8.2

Published artifacts org.jboss.shrinkwrap

  • org.jboss.shrinkwrap » shrinkwrap-api jar javadoc pom
  • org.jboss.shrinkwrap » shrinkwrap-bom pom
  • org.jboss.shrinkwrap » shrinkwrap-depchain pom
  • org.jboss.shrinkwrap » shrinkwrap-impl-base jar javadoc pom
  • org.jboss.shrinkwrap » shrinkwrap-spi jar javadoc pom

Release notes and resolved issues 3

Feature Request
  • SHRINKWRAP-404 - Expose underlying Asset source in the individual API's
Bug
Task

Thanks to the following list of contributors: Ralf Battenfeld, Andrew Lee Rubinger, Marek Goldmann

ShrinkWrap Descriptors 2.0.0-alpha-3 Released

Since we wrote this post we didn't laze around. Check our latest announcement.

The Arquillian team is proud to announce the 2.0.0-alpha-3 release of the ShrinkWrap Descriptors component!

What is ShrinkWrap Descriptors?

The Shrinkwrap Descriptor project provides an uniformed fluent API for creating and modifying Java EE deployment descriptors on the fly. Starting from the very early JEE 1.3 to the brand new Java EE 7 version, the descriptor project includes almost all official deployment descriptors. Several vendor specific deployment descriptors, mostly JBoss related, are covered as well.

Release details

Component ShrinkWrap Descriptors
Version 2.0.0-alpha-3 view tag
Release date 2012-05-10
Released by Andrew Lee Rubinger
Compiled against
  • JUnit – 4.8.1

Published artifacts org.jboss.shrinkwrap.descriptors

  • org.jboss.shrinkwrap.descriptors » shrinkwrap-descriptors-api-base jar javadoc pom
  • org.jboss.shrinkwrap.descriptors » shrinkwrap-descriptors-api-javaee jar javadoc pom
  • org.jboss.shrinkwrap.descriptors » shrinkwrap-descriptors-api-jboss jar javadoc pom
  • org.jboss.shrinkwrap.descriptors » shrinkwrap-descriptors-api-misc jar javadoc pom
  • org.jboss.shrinkwrap.descriptors » shrinkwrap-descriptors-bom pom
  • org.jboss.shrinkwrap.descriptors » shrinkwrap-descriptors-depchain pom
  • org.jboss.shrinkwrap.descriptors » shrinkwrap-descriptors-gen jar javadoc pom
  • org.jboss.shrinkwrap.descriptors » shrinkwrap-descriptors-impl-base jar javadoc pom
  • org.jboss.shrinkwrap.descriptors » shrinkwrap-descriptors-impl-javaee jar javadoc pom
  • org.jboss.shrinkwrap.descriptors » shrinkwrap-descriptors-impl-jboss jar javadoc pom
  • org.jboss.shrinkwrap.descriptors » shrinkwrap-descriptors-impl-misc jar javadoc pom
  • org.jboss.shrinkwrap.descriptors » shrinkwrap-descriptors-spi jar javadoc pom
  • org.jboss.shrinkwrap.descriptors » shrinkwrap-descriptors-test jar javadoc pom
  • org.jboss.shrinkwrap.descriptors » shrinkwrap-descriptors-test-util jar javadoc pom
  • org.jboss.shrinkwrap.descriptors » shrinkwrap-descriptors-metadata-parser-test jar javadoc pom

Release notes and resolved issues 6

Feature Request
Bug
Task

Thanks to the following list of contributors: Andrew Lee Rubinger, Jeremie Lagarde, Ralf Battenfeld, Craig Ringer