Arquillian Spring Framework Extension 1.0.0.Beta1 Released

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

The first Beta release of the Arquillian Spring extension is here.

Some of the highlights in this release

Client side application context registration
Spring transaction support

Client side tests with Spring

So far the Spring extension has only allowed application context creation and bean injection to occure when the tests were deployed in a container. We wanted to bring the same functionality to the client side. With the two new annotations @SpringClientConfiguration and @SpringClientAnnotationConfiguration it is now possible to set up the application context and inject beans into Arquillian tests that are running on the client.

An example of use would be to test a deployed REST service using the Spring RestTemplate configured in the client context.

@RunWith(Arquillian.class)
@SpringClientConfiguration("applicationContext-rest.xml")
public class ClientRestServiceTestCase {

    @Deployment(testable = false)
    @OverProtocol("Servlet 3.0")
    public static Archive createTestArchive() {
        return Deployments.createWebApplication()
                .addAsWebInfResource("mvc/web.xml", "web.xml")
                .addAsWebInfResource("service-servlet.xml");
    }

    @ArquillianResource
    private URL contextPath;

    @Autowired
    private RestTemplate restTemplate;

    @Test
    public void testGetEmployees() {

        Employee result = restTemplate.getForObject(contextPath + "/Employees/1", Employee.class);

        assertEquals("The returned employee has invalid name.", "John Smith", result.getName());
    }
}

Spring transaction support

The recent release of the Arquillian Transaction Extension allow us to control the transactional behavior of our test methods. With the help of the Spring Extension you can now control your Spring configured transaction manager using the same API. The set up is done in the normal Spring way by defining a transaction manager in the application context.

applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:tx="http://www.springframework.org/schema/tx"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">

   <!-- Creates local entity manager factory -->
   <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
       <property name="persistenceUnitName" value="ArquillianTestUnit"/>
   </bean>

   <!-- Enables the declarative transaction support -->
   <tx:annotation-driven transaction-manager="txManager"/>

   <!-- Creates transaction manager -->
   <bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager">
       <property name="entityManagerFactory" ref="entityManagerFactory"/>
   </bean>

</beans>

You define which transaction manager to use in your test class via the manager attribute on the @Transactional annotation.

@RunWith(Arquillian.class)
@Transactional(manager = "txManager")
@SpringConfiguration("applicationContext.xml")
public class JpaEmployeeRepositoryTestCase {

    @Autowired
    private EmployeeRepository employeeRepository;

    @PersistenceContext
    private EntityManager entityManager;

    @Test
    public void testSave() {

        Employee employee = new Employee();
        employee.setName("Test employee");

        employeeRepository.save(employee);

        List<Employee> result = entityManager.createQuery("from Employee").getResultList();

        assertEquals("Two employees were expected.", 1, result.size());
    }
}

Migrating from 1.0.0.Alpha2

  • Artifact arquillian-container-spring has been renamed to arquillian-service-container-spring

We look forward to your feedback on this new release on 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.Beta1 view tag
Release date 2012-08-17
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-3 jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-service-integration-spring jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-service-container-spring jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-service-integration-spring-inject jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-service-integration-spring-javaconfig jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-transaction-spring jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-service-integration-spring-2.5-int-tests jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-service-integration-spring-3-int-tests jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-warp-spring jar javadoc pom

Release notes and resolved issues 3

Arquillian Transaction Extension support and Client side ApplicationContext creation

Feature Request
  • ARQ-958 - Provide support for Spring transactions
  • ARQ-985 - Register the Spring Extension on client side.

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

Arquillian Spring Framework Extension 1.0.0.Beta1 Released

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

The first Beta release of the Arquillian Spring extension is here.

Some of the highlights in this release

Client side application context registration
Spring transaction support

Client side tests with Spring

So far the Spring extension has only allowed application context creation and bean injection to occure when the tests were deployed in a container. We wanted to bring the same functionality to the client side. With the two new annotations @SpringClientConfiguration and @SpringClientAnnotationConfiguration it is now possible to set up the application context and inject beans into Arquillian tests that are running on the client.

An example of use would be to test a deployed REST service using the Spring RestTemplate configured in the client context.

@RunWith(Arquillian.class)
@SpringClientConfiguration("applicationContext-rest.xml")
public class ClientRestServiceTestCase {

    @Deployment(testable = false)
    @OverProtocol("Servlet 3.0")
    public static Archive createTestArchive() {
        return Deployments.createWebApplication()
                .addAsWebInfResource("mvc/web.xml", "web.xml")
                .addAsWebInfResource("service-servlet.xml");
    }

    @ArquillianResource
    private URL contextPath;

    @Autowired
    private RestTemplate restTemplate;

    @Test
    public void testGetEmployees() {

        Employee result = restTemplate.getForObject(contextPath + "/Employees/1", Employee.class);

        assertEquals("The returned employee has invalid name.", "John Smith", result.getName());
    }
}

Spring transaction support

The recent release of the Arquillian Transaction Extension allow us to control the transactional behavior of our test methods. With the help of the Spring Extension you can now control your Spring configured transaction manager using the same API. The set up is done in the normal Spring way by defining a transaction manager in the application context.

applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:tx="http://www.springframework.org/schema/tx"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">

   <!-- Creates local entity manager factory -->
   <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
       <property name="persistenceUnitName" value="ArquillianTestUnit"/>
   </bean>

   <!-- Enables the declarative transaction support -->
   <tx:annotation-driven transaction-manager="txManager"/>

   <!-- Creates transaction manager -->
   <bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager">
       <property name="entityManagerFactory" ref="entityManagerFactory"/>
   </bean>

</beans>

You define which transaction manager to use in your test class via the manager attribute on the @Transactional annotation.

@RunWith(Arquillian.class)
@Transactional(manager = "txManager")
@SpringConfiguration("applicationContext.xml")
public class JpaEmployeeRepositoryTestCase {

    @Autowired
    private EmployeeRepository employeeRepository;

    @PersistenceContext
    private EntityManager entityManager;

    @Test
    public void testSave() {

        Employee employee = new Employee();
        employee.setName("Test employee");

        employeeRepository.save(employee);

        List<Employee> result = entityManager.createQuery("from Employee").getResultList();

        assertEquals("Two employees were expected.", 1, result.size());
    }
}

Migrating from 1.0.0.Alpha2

  • Artifact arquillian-container-spring has been renamed to arquillian-service-container-spring

We look forward to your feedback on this new release on 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.Beta1 view tag
Release date 2012-08-17
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-3 jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-service-integration-spring jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-service-container-spring jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-service-integration-spring-inject jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-service-integration-spring-javaconfig jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-transaction-spring jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-service-integration-spring-2.5-int-tests jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-service-integration-spring-3-int-tests jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-warp-spring jar javadoc pom

Release notes and resolved issues 3

Arquillian Transaction Extension support and Client side ApplicationContext creation

Feature Request
  • ARQ-958 - Provide support for Spring transactions
  • ARQ-985 - Register the Spring Extension on client side.

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

Arquillian Spring Framework Extension 1.0.0.Alpha2 Released

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

This release contain many improvements on the existing extension, but also some new features.

Some of the highlights in this release

Warp Spring MVC Extension
Spring Embedded Container
Separated the integration capabilities

Testing Spring MVC with Warp

Arquillian Warp is a powerful tool that let you run the functional tests against your web front end and at the same time verify the internal state of your application. With this release we are introducing the Warp extension for testing Spring MVC applications that run in a real servlet container.

Let’s dive into an example of how to test a Spring MVC application using Arquillian Warp. First we need to prepare the application descriptor.

web.xml
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         version="3.0">

    <servlet>
        <servlet-name>welcome</servlet-name>
        <servlet-class>org.jboss.arquillian.warp.extension.spring.servlet.WarpDispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>welcome</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>

</web-app>

You’ll notice that instead of using Spring’s DispatcherServlet we instead use the WarpDispatcherServlet.

And the testing code:

LoginControllerTestCase.java
@WarpTest
@RunWith(Arquillian.class)
public class LoginControllerTestCase {

    @Drone
    WebDriver browser;

    @ArquillianResource
    URL contextPath;

    @Test
    @RunAsClient
    public void testLoginValidationErrors() {
        browser.navigate().to(contextPath + "login.do");

        Warp.execute(new ClientAction() {

            @Override
            public void action() {

                browser.findElement(By.id("loginForm")).submit();
            }
        }).verify(new LoginControllerValidationErrorsVerification());
    }

    @Test
    @RunAsClient
    public void testLoginSuccess() {
        browser.navigate().to(contextPath + "login.do");
        browser.findElement(By.id("login")).sendKeys("warp");
        browser.findElement(By.id("password")).sendKeys("warp");

        Warp.execute(new ClientAction() {

            @Override
            public void action() {

                browser.findElement(By.id("loginForm")).submit();
            }
        }).verify(new LoginSuccessVerification());
    }

    public static class LoginControllerValidationErrorsVerification extends ServerAssertion {

            private static final long serialVersionUID = 1L;

            @SpringMvcResource
            private ModelAndView modelAndView;

            @SpringMvcResource
            private Errors errors;

            @AfterServlet
            public void testGetLogin() {

                assertEquals("login", modelAndView.getViewName());
                assertNotNull(modelAndView.getModel().get("userCredentials"));
                assertEquals("Two errors were expected.", 2, errors.getAllErrors().size());
                assertTrue("The login hasn't been validated.", errors.hasFieldErrors("login"));
                assertTrue("The password hasn't been validated.", errors.hasFieldErrors("password"));
            }
        }

    public static class LoginSuccessVerification extends ServerAssertion {

        private static final long serialVersionUID = 1L;

        @SpringMvcResource
        private ModelAndView modelAndView;

        @SpringMvcResource
        private Errors errors;

        @AfterServlet
        public void testGetLogin() {

            assertEquals("welcome", modelAndView.getViewName());
            assertFalse(errors.hasErrors());
        }
    }
}

In the above example we are using Arquillian Drone to navigate to the login page of our application and then filling in the login form with our user credentials.

The internal state of the DispatcherServlet is caught in a SpringMvcResult object which can be injected into the ServerAssertion. We can also inject other required objects like the ModelAndView.

Spring Embedded Container

Each development cycle may end in repeatedly re-running the integration tests, each time taking significant amount of time. The embedded container was thought to aid this situation. Running the tests embedded will decrease the execution time from seconds to milliseconds. It will help testing business objects, but since it’s not a full servlet container you won’t be able to use it for testing servlet requests in a web application.

Migrating from 1.0.0.Alpha1

1.0.0.Alpha2 comes with a couple significant changes from the previous version.

  • The Spring integration functionality has been separated out to its own module and is now part of the arquillian-service-integration-spring-inject module, and additional the arquillian-service-integration-spring-inject and the arquillian-service-integration-spring-javaconfig that does not target any specific Spring version, but rather provide functionality like XML or Java-based configuration.
  • The arquillian-service-deployer-spring module’s can still be used for autopackging the Spring artifacts.
  • The @SpringAnnotatedConfiguration has been renamed to @SpringAnnotationConfiguration.

Roadmap

The next release is planned to include Spring transaction support and will introduce even better Warp integration on the client side in order make REST testing even simpler.

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.Alpha2 view tag
Release date 2012-07-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-3 jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-service-integration-spring jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-container-spring jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-service-integration-spring-inject jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-service-integration-spring-javaconfig jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-service-integration-spring-2.5-int-tests jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-service-integration-spring-3-int-tests jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-warp-spring jar javadoc pom

Release notes and resolved issues 5

Spring Embedded Container + Warp

Feature Request
  • ARQ-219 - Implement an embedded Spring container
  • ARQ-945 - Extract Spring Integration out of Spring Deployer
  • ARQ-978 - Provide Warp with extension for testing SpringMVC.
Task
  • ARQ-1019 - Spring Extension: Update the Arquiilian Core to 1.0.1

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

Arquillian Spring Framework Extension 1.0.0.Alpha2 Released

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

This release contain many improvements on the existing extension, but also some new features.

Some of the highlights in this release

Warp Spring MVC Extension
Spring Embedded Container
Separated the integration capabilities

Testing Spring MVC with Warp

Arquillian Warp is a powerful tool that let you run the functional tests against your web front end and at the same time verify the internal state of your application. With this release we are introducing the Warp extension for testing Spring MVC applications that run in a real servlet container.

Let’s dive into an example of how to test a Spring MVC application using Arquillian Warp. First we need to prepare the application descriptor.

web.xml
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         version="3.0">

    <servlet>
        <servlet-name>welcome</servlet-name>
        <servlet-class>org.jboss.arquillian.warp.extension.spring.servlet.WarpDispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>welcome</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>

</web-app>

You’ll notice that instead of using Spring’s DispatcherServlet we instead use the WarpDispatcherServlet.

And the testing code:

LoginControllerTestCase.java
@WarpTest
@RunWith(Arquillian.class)
public class LoginControllerTestCase {

    @Drone
    WebDriver browser;

    @ArquillianResource
    URL contextPath;

    @Test
    @RunAsClient
    public void testLoginValidationErrors() {
        browser.navigate().to(contextPath + "login.do");

        Warp.execute(new ClientAction() {

            @Override
            public void action() {

                browser.findElement(By.id("loginForm")).submit();
            }
        }).verify(new LoginControllerValidationErrorsVerification());
    }

    @Test
    @RunAsClient
    public void testLoginSuccess() {
        browser.navigate().to(contextPath + "login.do");
        browser.findElement(By.id("login")).sendKeys("warp");
        browser.findElement(By.id("password")).sendKeys("warp");

        Warp.execute(new ClientAction() {

            @Override
            public void action() {

                browser.findElement(By.id("loginForm")).submit();
            }
        }).verify(new LoginSuccessVerification());
    }

    public static class LoginControllerValidationErrorsVerification extends ServerAssertion {

            private static final long serialVersionUID = 1L;

            @SpringMvcResource
            private ModelAndView modelAndView;

            @SpringMvcResource
            private Errors errors;

            @AfterServlet
            public void testGetLogin() {

                assertEquals("login", modelAndView.getViewName());
                assertNotNull(modelAndView.getModel().get("userCredentials"));
                assertEquals("Two errors were expected.", 2, errors.getAllErrors().size());
                assertTrue("The login hasn't been validated.", errors.hasFieldErrors("login"));
                assertTrue("The password hasn't been validated.", errors.hasFieldErrors("password"));
            }
        }

    public static class LoginSuccessVerification extends ServerAssertion {

        private static final long serialVersionUID = 1L;

        @SpringMvcResource
        private ModelAndView modelAndView;

        @SpringMvcResource
        private Errors errors;

        @AfterServlet
        public void testGetLogin() {

            assertEquals("welcome", modelAndView.getViewName());
            assertFalse(errors.hasErrors());
        }
    }
}

In the above example we are using Arquillian Drone to navigate to the login page of our application and then filling in the login form with our user credentials.

The internal state of the DispatcherServlet is caught in a SpringMvcResult object which can be injected into the ServerAssertion. We can also inject other required objects like the ModelAndView.

Spring Embedded Container

Each development cycle may end in repeatedly re-running the integration tests, each time taking significant amount of time. The embedded container was thought to aid this situation. Running the tests embedded will decrease the execution time from seconds to milliseconds. It will help testing business objects, but since it’s not a full servlet container you won’t be able to use it for testing servlet requests in a web application.

Migrating from 1.0.0.Alpha1

1.0.0.Alpha2 comes with a couple significant changes from the previous version.

  • The Spring integration functionality has been separated out to its own module and is now part of the arquillian-service-integration-spring-inject module, and additional the arquillian-service-integration-spring-inject and the arquillian-service-integration-spring-javaconfig that does not target any specific Spring version, but rather provide functionality like XML or Java-based configuration.
  • The arquillian-service-deployer-spring module’s can still be used for autopackging the Spring artifacts.
  • The @SpringAnnotatedConfiguration has been renamed to @SpringAnnotationConfiguration.

Roadmap

The next release is planned to include Spring transaction support and will introduce even better Warp integration on the client side in order make REST testing even simpler.

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.Alpha2 view tag
Release date 2012-07-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-3 jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-service-integration-spring jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-container-spring jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-service-integration-spring-inject jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-service-integration-spring-javaconfig jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-service-integration-spring-2.5-int-tests jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-service-integration-spring-3-int-tests jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-warp-spring jar javadoc pom

Release notes and resolved issues 5

Spring Embedded Container + Warp

Feature Request
  • ARQ-219 - Implement an embedded Spring container
  • ARQ-945 - Extract Spring Integration out of Spring Deployer
  • ARQ-978 - Provide Warp with extension for testing SpringMVC.
Task
  • ARQ-1019 - Spring Extension: Update the Arquiilian Core to 1.0.1

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

Arquillian Spring Framework Extension 1.0.0.Alpha1 Released

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