Arquillian Spring Framework Extension 1.0.0.Beta2 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.Beta2 release of the Arquillian Spring Framework Extension component!

It has been a while since that last Arquillian Spring extension release, but it’s finally here. This release focus more on improving existing features rather then introducing completely new ones.

I would like to thank Jakub Kurlenda and John Ament for helping with this release.

Some of the highlights in this release

Managing the Spring’s ApplicationContext lifecycle

New ways of configuring Spring’s context

Warp Spring extension

Deployer new functionality

Managing the Spring’s ApplicationContext lifecycle

Previous versions had one common drawback, each test were running using a separate instance of Spring’s ApplicationContext. Although the ApplicationContext were destroyed and all of its resources were freed after the test execution, this brought additional overhead for each test. From now on the developer has the control whether he want to create only a single context per test case or to have each test run with a new “clean” context, which in some situation might be handy. By default the context will be created only once, but it can easly be changed by adding the @ContextLifeCycle annotation to the test case.

New ways of configuring Spring’s context

This release also bring a couple of new features to ease the test configuration. First are smart defaults used for configuration. Each @SpringConfiguration annotated test do not need to explicitly define the location of the XML file anymore. If no file has been defined, by default the extension will look for file in classpath with exactly the same name as the class located in the class package. The same goes for @SpringAnnotationConfiguration, which now allow to add a static non final internal class which needs to be marked with @Configuration. The extension will use that class by default when configuring Spring.

Example:

@SpringClientAnnotationConfiguration
public class TestCase {

    @Configuration
    public static class ContextConfiguration {

        @Bean
        public EmployeeService employeeService() {
            return new EmployeeServiceImpl();
        }
    }
}

The last new feature is programmatic creation of the ApplicationContext from within a test. From now on it is possible to create the instance of the Spring ApplicationContext for each test via code. This is done by adding a static factory method to the test which needs to be annotated with @SpringContextConfiguration. The extension will invoke this method prior to test execution (all context lifecycle rules mentioned above also apply here) and use it’s result afterwards.

Example:

@SpringContextConfiguration
public static ApplicationContext contextConfiguration() {

   return new ClassPathXmlApplicationContext(
       new String[]{"classpath:service.xml", "classpath:repository.xml"});
}

Why would this be needed? In some cases you needs to have greater control over the context; for instance at the moment this is the only way to pragmatically set the Spring profiles to use for the test. The other possibility could be integration with other frameworks in which the context should not be managed by the test itself.

Warp Spring extension

The Warp Spring extension has been updated to the latest Alpha 2 release. For consistency with other Warp extensions the SpringMvcResult can be now injected using @ArquillianResource annotation. The custom @SpringResource has been deprecated and might be remove in next releases.

Deployer new functionality

The Spring deployer, which is used for automatic packaging the Spring artifacts and enriching the test deployment, has received some updates. It now allows for importing the dependencies directly from the Maven POM file, and could aid with setting up the deployment. The deployer can be configured in the arquillian.xml file through the spring-deployer section. Additional properties like pomFile allow you to specify the location of the pom file to load; useMavenOffline controls the offline mode of the maven resolver in use, and enableCache controls whether the deployer should cache the artifacts in memory. Finally the excludedArtifacts allow you to exclude artifacts that are unwanted from the deployment

<extension qualifier="spring-deployer">

        <property name="importPomDependencies">true</property>

        <property name="pomFile">src/main/resources/test_pom.xml</property>

        <property name="useMavenOffline">false</property>

        <property name="excludedArtifacts">org.jboss.arquillian:*</property>

        <property name="enableCache">true</property>
</extension>

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.Beta2 view tag
Release date 2013-06-19
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 16

Improvements

Feature Request
  • ARQ-960 - Provide the way to specify the strategy on instantiting AppllicationContext e.g. each test method or each test case
  • ARQ-1104 - Spring deployer should include all spring artifacts
  • ARQ-1105 - Spring deployer - add maven offline property
  • ARQ-1106 - Spring deployer - allow caching the resolved libraries between deployments
  • ARQ-1108 - Register the spring transaction provider on the client side.
  • ARQ-1134 - Spring deployer - change the implementation of MavenDependencyBuilder.
  • ARQ-1269 - Upgrade Spring MVC integration to use Warp 1.0.0.Alpha2.
  • ARQ-1270 - Upgrade Spring extension to Arquillian Core 1.0.3
  • ARQ-1277 - Allow the SpringMvcResult to be injected through @ArquillianResource.
  • ARQ-1304 - Create test ApplicationContext through factory method.
  • ARQ-1305 - Defaults values for @SpringConfiguration and @SpringAnnotationConfiguration
  • ARQ-1317 - Warp Spring MVC - capture the execution state through HandlerInterceptor
  • ARQ-1358 - Define ApplicationContext life cycle events.
  • ARQ-1408 - Upgrade Spring extension to Arquillian 1.0.4.Final.
Bug
  • ARQ-1079 - SpringEmbeddedApplicationContextProducer testApplicationContext is missing the scope definition.

Thanks to the following list of contributors: Jakub Narloch, Aslak Knutsen, John D. Ament, Jakub Kurlenda