Spring-test-mvc, @Configuration and 1 page test
I like how a very concise 1 page end to end controller test for a sample REST service is possible through a combination of @Configuration, Spring Testing Support and Spring-test-mvc.Here is the...
View ArticleEclipseLink MOXy as a JAXB provider
EclipseLink MOXy is a JAXB provider and is a compelling alternative to the default JAXB provider built into JDK.First a simple test to marshal a Java object to XML:This is the...
View ArticleSpring Integration - Session 2 - More Hello Worlds
This is a follow up to Spring Integration Session 1The first session was a simple Hello World application using Spring Integration. I want to take it a little further by considering a few more...
View ArticleAccept header vs Content-Type Header
I occasionally get confused between the Accept and the Content-Type Headers and this post is a way of clarifying the difference for myself. Let me summarize the difference to start with and then go...
View ArticleMergesort using Fork/Join Framework
The objective of this entry is to show a simple example of a Fork/Join RecursiveAction, not to delve too much into the possible optimizations to merge sort or the relative advantages of using Fork/Join...
View ArticleSpring @Configuration and FactoryBean
Consider a FactoryBean for defining a cache using a Spring configuration file:<cache:annotation-driven /><context:component-scan...
View Article@ContextConfiguration defaults
Spring @ContextConfiguration is a way to specify the Application Context for a test.The location of a xml based test application context can be specified using the locations...
View ArticleSpring Scoped Proxy
Consider two Spring beans defined this way:@Componentclass SingletonScopedBean{ @Autowired private PrototypeScopedBean prototypeScopedBean; public String getState(){ return...
View ArticleWays to wire dependencies for an object outside of a Spring Container
There are a few interesting ways of setting the properties and dependencies of an object instantiated outside of a Spring container. Use CasesTo start with, why would we need to do inject in...
View ArticleJava Annotations - Retention
Consider a Java annotation:public @interface AnAnnotaton {}A class with this annotation applied on it:@AnAnnotatonclass AnAnnotatedClass{}And a test which checks if this annotation is present on a...
View ArticleSpring Testing Support and Context caching
Spring provides a comprehensive support for unit and integration testing - through annotations to load up a Spring application context, integrate with unit testing frameworks like JUnit and TestNG....
View ArticleScala Iteration - step by 2*previous loop index
I had a basic Scala related question about how to replicate the following Java loop in Scala:for (int i=1;i<100000;i=2*i){ System.out.println(i);}I knew one way to go about doing this using a...
View ArticleSpring MVC - static resource handling with / servlet-mapping
A servlet mapping of "/" registers a "default" servlet - if a request comes in which matches a mapping in the web.xml file then the request will be handled by that servlet, however if no servlet is...
View ArticleSpring Autowire - Subtle behavior difference in xml and @Configuration
There is a subtle difference in the behavior of how autowire behaves with new @Configuration style of Spring bean configuration and using an xml file:Consider a service into which a Dao is wired...
View ArticleSpring Collection Merging
Spring collection merging is a feature that I first came across as an answer to a StackOverflowquestionIt is a way of creating a base collection (list, set, map or properties) and modifying this base...
View ArticleSpring Constructor Injection and parameter names
At runtime, java classes do not retain the name of the constructor or method parameters, unless classes are compiled with debug options on. This has some interesting implications for Spring Constructor...
View ArticleMethod Parameter Names and Spring
Continuing on the previous blog entry about Constructor and method parameters and Java not retaining the parameter names at runtime - the previous entry was about constructor not retaining the...
View ArticleJSP Expression Language and .class
This is something which I faced when using JSP-EL this week, consider the following JSP-EL statement which displays content based on the type of an object:<c:choose><c:when...
View ArticlePolling an http end point using Spring Integration
It is a little non-intuitive if you want to write a flow with Spring Integration which polls an http end point and gathers some content from the http end point for further processing.Spring Integration...
View ArticleSpring Integration Standalone application
Creating a standalone Spring application and by extension a Spring Integration application is very easy. As long as a non-daemon thread is active, the main thread does not terminate, so if the Spring...
View Article