Spring Framework 3.2 RC1: Spring MVC Test Framework

Engineering | Rossen Stoyanchev | November 12, 2012 | ...

[callout title=Update Dec 19, 2012] The final Spring Framework reference documentation contains guidance on migration as well as a complete section on Spring MVC Test. [/callout]

Last week Juergen Hoeller announced the release of Spring Framework 3.2 RC1 and Sam Brannen discussed exciting additions in its spring-test module such as support for WebApplicationContext's and upcoming plans for loading a hierarchy of contexts. Today I will continue this subject and describe another exciting spring-test addition. In 3.2 RC1 we've added first class support for testing Spring MVC applications both…

Spring Framework 3.2 RC1: New Testing Features

Engineering | Sam Brannen | November 07, 2012 | ...

As Juergen Hoeller mentioned in his post announcing the release of Spring Framework 3.2 RC1, the Spring Team has introduced some exciting new features in terms of testing support. Most importantly, we've added first-class support for testing web applications. [1]

      Please note: this is a cross post from my Swiftmind company blog.

In this post we'll first take a look at some of the general new testing features in the Spring Framework, and then we'll go into detail regarding support for testing with a WebApplicationContext as well as request and session scoped beans. We'll close with a look at support for ApplicationContextInitializers and a brief discussion of the road map for testing with application context hierarchies.

Rossen Stoyanchev will later follow up with a detailed post on the new Spring MVC Test framework that provides first-class support for testing Spring MVC applications. So be sure to stay tuned for that as well, since it builds on the basic web testing support discussed later in this post.



General New Features and Updates


Build and Dependencies

The spring-test module now builds against and supports JUnit 4.10 and TestNG 6.5.2, and spring-test now depends on the junit:junit-dep Maven artifact instead of junit:junit which means that you have full control over your dependencies on Hamcrest libraries (e.g., hamcrest-core, hamcrest-all, etc.).

Generic Factory Methods

Generic factory methods are methods that implement the Factory Method Design Pattern using Java Generics. Here are some example signatures of generic factory methods:


public static <T> T mock(Class<T> clazz) { ... }

public static <T> T proxy(T obj) { ... }

The use of generic factory methods in Spring configuration is by no means specific to testing, but generic factory methods such as EasyMock.createMock(MyService.class) or Mockito.mock(MyService.class) are often used to create dynamic mocks for Spring beans in a test application context. For example, prior to Spring Framework 3.2 the following configuration could fail to autowire the OrderRepository into the OrderService. The reason is that, depending on the order in which beans are initialized in the application context, Spring would potentially infer the type of the orderRepository bean to be java.lang.Object instead of com.example.repository.OrderRepository.


<beans>

  <!-- OrderService is autowired with OrderRepository -->
  <context:component-scan base-package="com.example.service"/>

  <bean id="orderRepository" class="org.easymock.EasyMock…

A Groovy DSL For Spring Integration

Engineering | David Turanski | November 06, 2012 | ...

Spring Integration implements Enterprise Integration Patterrns using the Spring programming model to enable messaging in Spring-based applications. Spring Integration also provides integration with external systems using declarative adapters supporting jms, http, amqp, tcp, ftp(s), smtp, and so on. Currently, configuring message flows is primarily done via Spring XML and Spring Integration supports several namespaces to make this as succinct as possible. Earlier this year, SpringSource released a Scala DSL for Spring Integration. Now, we are pleased to announce the first milestone release…

This Week in Spring - 6 November, 2012

Engineering | Josh Long | November 06, 2012 | ...

Welcome back to another installment of This Week in Spring! We've got a lot to cover, so let's get to it!

  1. Did you guys miss SpringOne2GX 2012? I'm not going to lie to you - you really missed out! However, don't despair! Two of my absolute favorite talks from the show are now available online - the keynotes! Both were amazing, but if you're looking for an amazing introduction to the trends underlying next generation of web applications, and a great (amazing!) tour of RabbitMQ, check out the day 2 keynote!
    	More sessions will be posted on that page, so check back often.</LI>
     <LI> Spring 3.2 is drawing ever nearer!   The H  has some 
    	<a href  ="http://www.h-online.com/open/news/item/Spring-Framework-3-2-nears-with-release-candidate-1744277.html">nice coverage of the new features  in the framework</a>.
     </LI>
     <LI> Chris Beams  has announced the latest maintenance release, <A href="http://www.springsource.org/node/3720">Spring 3.1.3 - the third in the 3.1 line, has been released</a>! 
    
  2. Guys, I'm so excited to tell you that SpringOne is coming to India! Register now!
  3. Does your PaaS support your workloads? If you're using Cloud Foundry, then chances are good that it does!
  4. Michael Isvy has put together a nice post on Spring MVC and the view layer
  5. The Spring Framework TestContext framework now supports session/request scoped beans for integration testing
  6. The first milestone of Spring Data SOLR has been released!
  7. Jonathan Brisbin has announced the 1.2 release of the Spring REST Shell. The new release features SSL, basic auth, dotrc support, an updated Homebrew install formula, HATEOAS and hypermedia.
  8. Check out Costin Leau's webinar introducing Spring Data Hadoop this Thursday!
  9. RabbitMQ developer advocate Alvaro Videla linked to a great post on visualizing RabbitMQ topologies.
  10. Spring Data Batch and Spring Security OAuth ninja and Cloud Foundry UAA committer Dr. David Syer has written a really fantastic post on using Cloud Foundry's UAA agents OAuth2 endpoint. This has scarce little to do with Spring, except that Dr. Syer's posts are very educational and helped me tremendously in understanding the problems that Spring Security OAuth solves.

Spring Framework 3.2 RC1 released

Engineering | Juergen Hoeller | November 05, 2012 | ...

Dear Spring community,

I'm pleased to announce that the first Spring Framework 3.2 release candidate is now available.

This generation of the core framework is a straightforward next step after last year's Spring Framework 3.1, continuing several well-established themes. Key features in Spring Framework 3.2 include:

  • A new Gradle-based framework build, making it easier than ever to contribute to the Spring Framework project on GitHub
  • Inlined CGLIB 3.0 and ASM 4.0, fully supporting Java 7 byte code and making CGLIB-based functionality available without explicit declaration of a CGLIB dependency
  • Allowing for @Autowired and @Value to be used as meta-annotations, e.g. to build custom injection annotations in combination with specific qualifiers
  • Support for custom @Bean definition annotations in @Configuration classes, e.g. in combination with specific qualifiers, @Lazy, @Primary, etc
  • Asynchronous MVC processing on Servlet 3.0

First milestone of Spring Data Solr released

Releases | Oliver Drotbohm | October 31, 2012 | ...

I am pleased to announce the availablity of the first milestone of a Spring Data Solr project. It's the first community-driven Spring Data module lead by Christoph Strobl. It's essentially an implementation of the Spring Data repository API to access Solr stores and provides the same programming model you are already used to from Spring Data JPA, MongoDB, Neo4j and Gemfire. Beyond that Spring Data Solr provides a lower level SolrTemplate as well as abstractions to easily bootstrap an embedded Solr server.

Maven artifacts | JavaDocs | Reference Documentation | Changelog | JIRA

We looking forward to community-driven Spring Data module implementations for other stores. Please get in touch with us through the forums in case you'd like to see a particular store supported and can commit to actively maintaining the project.

This Week in Spring - 30 October, 2012

Engineering | Josh Long | October 31, 2012 | ...

Welcome to another installment of This Week in Spring!

  1. Spring Data GemFire 1.2.1 and GemFire 7.0 have been released! The new Spring Data release includes complete Spring XML namespace support for configuration of all GemFire resources, eliminating the need for GemFire's native cache XML (cache XML is also supported), and Spring Data Repositories for GemFire. Also of note, the GemFire shell (gfsh) was built with Spring Shell. For more on the GemFire 7.0 release, be sure to check out the post which in turn links to release notes and documentation.
  2. 					<LI> Michael Isvy  has put together a nice blog <a href=" http://blog.springsource.org/2012/10/30/spring-mvc-from-jsp-and-tiles-to-thymeleaf/">on moving from JSP and Tiles to Thymeleaf</a>, a new view layer that works particularly well with Spring MVC (and that we have talked about quite a bit in this very roundup for the last few years!).</LI>
    <LI>
    	Spring Security lead Rob Winch has done a nice interview with InfoQ on <A href= "http://www.infoq.com/interviews/robert-winch-spring-security-multi-tenant-applications"> Spring Security  in multi-tenant appications on the cloud</a>  </LI…

Spring MVC: from JSP and Tiles to Thymeleaf

Engineering | Michael Isvy | October 30, 2012 | ...

When it comes to the view layer, Spring @MVC gives you a variety of choices. In this article, we will first discuss the way you have most likely used the view layer in the past few years: JSP. We will see the bad and better ways to work with them (plain JSP, JSP with custom tags, Apache Tiles).

We will then discuss a new project called Thymeleaf, which you can use as an alternate approach to JSP.

As usual, you can find all the code samples discussed in the corresponding application on github.

Plain JSP

Let us get started with the below code sample:

<html …> <body>
 <div style="padding-top: 50px;">
   <jsp:include page="../menu.jspx"/>
   <c…

Get the Spring newsletter

Thank you for your interest. Someone will get back to you shortly.

Get ahead

VMware offers training and certification to turbo-charge your progress.

Learn more

Get support

Tanzu Spring Runtime offers support and binaries for OpenJDK™, Spring, and Apache Tomcat® in one simple subscription.

Learn more

Upcoming events

Check out all the upcoming events in the Spring community.

View all