Sunday, 25 November 2012

Testing with embedded mongodb

If you have to use embedded mongodb instance for testing there is a foursquare implementation called Fongo. You will have to install it locally or deploy it into your intranet repository in order to use with maven.

In order to use it with spring-data-mongodb you can use something like


1:  <bean id="mongoOperations" class="ru.sample.dal.utils.ImMemoryMongoFactory" factory-method="provide" scope="prototype"/>
2:  
3:  <bean id="mongoTemplate" class="ru.sample.dal.utils.ImMemoryMongoFactory" factory-method="provide" scope="prototype"/>
4:  
5:  public class ImMemoryMongoFactory {
6:    private static Fongo fongo = new Fongo("name");
7:  
8:    public static MongoOperations provide() {
9:      return new MongoTemplate(fongo.getMongo(), "database");
10:    }
11:  }


and just autore MongoOperations in your custom repository implemenations. Basic implementation of repositories should start using those beans by default too

Saturday, 24 November 2012

Stable WADL Maven plugin.

If your project is currently using

<dependency>
<groupId>org.jvnet.ws.wadl</groupId>
<artifactId>wadl-maven-plugin</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
 and you are looking for stable version of a plugin, you should be using following:

<groupId>org.jvnet.ws.wadl</groupId>
<artifactId>wadl-client-plugin</artifactId>
 <version>1.1.3</version>
this is the most recent and least bogous version of plugin. Nothat you will have to refactor code if you was using client generated by wadl plugin. Also note that to reach endpoints with compound paths like
"/{classPath}/{methodPath}"  you will have to create java instance of generated client's {classPath} instance first and get reference to {methodPath} inner class instance from it in order for client to build URI's appropriately.