- Use Joda DateTime instead of java.utils.Date user_management
authorymh <ymh.work@gmail.com>
Fri, 15 Nov 2013 09:34:41 +0100
branchuser_management
changeset 232 b7000ff4989b
parent 231 e65766f81b15
child 233 bf599928e1ad
- Use Joda DateTime instead of java.utils.Date - use correct version of jackson
.classpath
server/README.md
server/pom.xml
server/src/main/java/org/iri_research/renkan/controller/admin/UsersAdminController.java
server/src/main/java/org/iri_research/renkan/coweb/RenkanSessionModerator.java
server/src/main/java/org/iri_research/renkan/coweb/event/AbstractSyncEventManager.java
server/src/main/java/org/iri_research/renkan/forms/SpaceForm.java
server/src/main/java/org/iri_research/renkan/forms/SpaceFormValidator.java
server/src/main/java/org/iri_research/renkan/forms/UserForm.java
server/src/main/java/org/iri_research/renkan/forms/UserFormValidator.java
server/src/main/java/org/iri_research/renkan/models/Project.java
server/src/main/java/org/iri_research/renkan/models/ProjectRevision.java
server/src/main/java/org/iri_research/renkan/models/ProjectSync.java
server/src/main/java/org/iri_research/renkan/models/Space.java
server/src/main/java/org/iri_research/renkan/models/User.java
server/src/main/java/org/iri_research/renkan/repositories/ProjectSyncsRepositoryImpl.java
server/src/main/java/org/iri_research/renkan/rest/ObjectMapperProvider.java
server/src/main/java/org/iri_research/renkan/rest/ProjectsResource.java
server/src/main/java/org/iri_research/renkan/rest/RenkanResource.java
server/src/main/java/org/iri_research/renkan/rest/RestApplication.java
server/src/main/java/org/iri_research/renkan/rest/SpacesResource.java
server/src/main/webapp/WEB-INF/applicationContext.xml
server/src/test/java/org/iri_research/renkan/test/controller/AdminControllerTest.java
server/src/test/java/org/iri_research/renkan/test/controller/SpacesAdminControllerTest.java
server/src/test/java/org/iri_research/renkan/test/controller/UsersAdminControllerTest.java
server/src/test/java/org/iri_research/renkan/test/repositories/ProjectSyncsRepositoryTest.java
server/src/test/java/org/iri_research/renkan/test/repositories/ProjectsRepositoryTest.java
server/src/test/java/org/iri_research/renkan/test/repositories/SpacesRepositoryTest.java
server/src/test/java/org/iri_research/renkan/test/rest/ProjectRestTest.java
server/src/test/java/org/iri_research/renkan/test/rest/SpaceRestTest.java
server/src/test/resources/org/iri_research/renkan/test/controller/controller-context.xml
--- a/.classpath	Thu Nov 07 10:42:18 2013 +0100
+++ b/.classpath	Fri Nov 15 09:34:41 2013 +0100
@@ -199,7 +199,9 @@
 	<classpathentry kind="var" path="M2_REPO/org/glassfish/jersey/test-framework/jersey-test-framework-core/2.3.1/jersey-test-framework-core-2.3.1.jar"/>
 	<classpathentry kind="var" path="M2_REPO/org/glassfish/jersey/ext/jersey-spring3/2.3.1/jersey-spring3-2.3.1.jar"/>
 	<classpathentry kind="var" path="M2_REPO/javax/ws/rs/javax.ws.rs-api/2.0/javax.ws.rs-api-2.0.jar"/>
-	<classpathentry kind="var" path="M2_REPO/org/glassfish/jersey/media/jersey-media-json-jackson/2.3.1/jersey-media-json-jackson-2.3.1.jar"/>
 	<classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar"/>
+	<classpathentry kind="var" path="M2_REPO/com/fasterxml/jackson/datatype/jackson-datatype-joda/2.2.3/jackson-datatype-joda-2.2.3.jar"/>
+	<classpathentry kind="var" path="M2_REPO/com/fasterxml/jackson/jaxrs/jackson-jaxrs-json-provider/2.2.3/jackson-jaxrs-json-provider-2.2.3.jar"/>
+	<classpathentry kind="var" path="M2_REPO/com/fasterxml/jackson/jaxrs/jackson-jaxrs-base/2.2.3/jackson-jaxrs-base-2.2.3.jar"/>
 	<classpathentry kind="output" path="server/target/classes"/>
 </classpath>
--- a/server/README.md	Thu Nov 07 10:42:18 2013 +0100
+++ b/server/README.md	Fri Nov 15 09:34:41 2013 +0100
@@ -6,4 +6,4 @@
 - cf pom.xml for dependencies
 
 Commandes maven:
-mvn -DskipTests -Djava.awt.headless=true clean jetty:run-war
+mvn -DskipTests -Djava.awt.headless=true -Duser.timezone="UTC" clean jetty:run-war
--- a/server/pom.xml	Thu Nov 07 10:42:18 2013 +0100
+++ b/server/pom.xml	Fri Nov 15 09:34:41 2013 +0100
@@ -247,37 +247,15 @@
             <artifactId>jersey-server</artifactId>
             <version>${jersey-version}</version>
         </dependency>
-        <dependency>
+        <!--dependency>
             <groupId>org.glassfish.jersey.media</groupId>
             <artifactId>jersey-media-json-jackson</artifactId>
             <version>${jersey-version}</version>
-        </dependency>
+        </dependency-->
         <dependency>
             <groupId>org.glassfish.jersey.ext</groupId>
             <artifactId>jersey-spring3</artifactId>
             <version>${jersey-version}</version>
-            <!--exclusions>
-                <exclusion>
-                    <groupId>org.springframework</groupId>
-                    <artifactId>spring-context</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.springframework</groupId>
-                    <artifactId>spring-beans</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.springframework</groupId>
-                    <artifactId>spring-core</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.springframework</groupId>
-                    <artifactId>spring-web</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.springframework</groupId>
-                    <artifactId>spring-aop</artifactId>
-                </exclusion>
-            </exclusions-->
         </dependency>
         <dependency>
             <groupId>org.glassfish.jersey.test-framework.providers</groupId>
@@ -394,6 +372,11 @@
             <version>${jackson-version}</version>
         </dependency>
         <dependency>
+            <groupId>com.fasterxml.jackson.datatype</groupId>
+            <artifactId>jackson-datatype-joda</artifactId>
+            <version>${jackson-version}</version>
+        </dependency>  
+        <dependency>
             <groupId>commons-codec</groupId>
             <artifactId>commons-codec</artifactId>
             <version>${commons-codec-version}</version>
--- a/server/src/main/java/org/iri_research/renkan/controller/admin/UsersAdminController.java	Thu Nov 07 10:42:18 2013 +0100
+++ b/server/src/main/java/org/iri_research/renkan/controller/admin/UsersAdminController.java	Fri Nov 15 09:34:41 2013 +0100
@@ -2,12 +2,9 @@
 
 import java.security.NoSuchAlgorithmException;
 import java.security.SecureRandom;
-import java.text.SimpleDateFormat;
 import java.util.Arrays;
-import java.util.Date;
 import java.util.Locale;
 import java.util.Map;
-import java.util.TimeZone;
 
 import javax.annotation.Resource;
 import javax.inject.Inject;
@@ -25,7 +22,6 @@
 import org.iri_research.renkan.repositories.UsersRepository;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.propertyeditors.CustomDateEditor;
 import org.springframework.beans.propertyeditors.StringTrimmerEditor;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
@@ -68,12 +64,6 @@
 
     @InitBinder
     public void initDateBinder(final WebDataBinder dataBinder, final Locale locale) {
-        final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-        sdf.setLenient(false);
-        sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
-        CustomDateEditor cde = new CustomDateEditor(sdf, true);
-        dataBinder.registerCustomEditor(Date.class, cde);
-        
         dataBinder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
     }
 
--- a/server/src/main/java/org/iri_research/renkan/coweb/RenkanSessionModerator.java	Thu Nov 07 10:42:18 2013 +0100
+++ b/server/src/main/java/org/iri_research/renkan/coweb/RenkanSessionModerator.java	Fri Nov 15 09:34:41 2013 +0100
@@ -16,6 +16,7 @@
 
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.datatype.joda.JodaModule;
 
 public class RenkanSessionModerator extends DefaultSessionModerator {
 
@@ -225,6 +226,7 @@
 
         Map<String, Object> res = super.getLateJoinState();
         ObjectMapper mapper = new ObjectMapper();
+        mapper.registerModule(new JodaModule());
 
         for (String clientId : RenkanSessionModeratorState.INSTANCE
                 .getUsersActivationMap().keySet()) {
--- a/server/src/main/java/org/iri_research/renkan/coweb/event/AbstractSyncEventManager.java	Thu Nov 07 10:42:18 2013 +0100
+++ b/server/src/main/java/org/iri_research/renkan/coweb/event/AbstractSyncEventManager.java	Fri Nov 15 09:34:41 2013 +0100
@@ -1,7 +1,6 @@
 package org.iri_research.renkan.coweb.event;
 
 import java.io.Serializable;
-import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -15,6 +14,7 @@
 import org.iri_research.renkan.repositories.IRenkanRepository;
 import org.iri_research.renkan.repositories.ProjectSyncsRepository;
 import org.iri_research.renkan.repositories.ProjectsRepository;
+import org.joda.time.DateTime;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -88,7 +88,7 @@
             return;
         }
 
-        p.setUpdated(new Date());
+        p.setUpdated(new DateTime());
         this.projectsRepository.save(p);
 
         user_id = (String) values.get("_user_id");
--- a/server/src/main/java/org/iri_research/renkan/forms/SpaceForm.java	Thu Nov 07 10:42:18 2013 +0100
+++ b/server/src/main/java/org/iri_research/renkan/forms/SpaceForm.java	Fri Nov 15 09:34:41 2013 +0100
@@ -1,11 +1,10 @@
 package org.iri_research.renkan.forms;
 
-import java.util.Date;
-
 import org.iri_research.renkan.Constants;
 import org.iri_research.renkan.models.Space;
 import org.iri_research.renkan.repositories.IRenkanRepository;
 import org.iri_research.renkan.repositories.SpacesRepository;
+import org.joda.time.DateTime;
 
 public class SpaceForm extends RenkanForm<String, Space> {
 
@@ -44,7 +43,7 @@
     protected void saveToModel() {
         if (this.getId() == null || this.getId().length() == 0) {
             this.model.setId(Constants.UUID_GENERATOR.generate().toString());
-            this.model.setCreated(new Date());
+            this.model.setCreated(new DateTime());
         }
         this.model.setBinConfig(binConfig);
         this.model.setImage(image);
--- a/server/src/main/java/org/iri_research/renkan/forms/SpaceFormValidator.java	Thu Nov 07 10:42:18 2013 +0100
+++ b/server/src/main/java/org/iri_research/renkan/forms/SpaceFormValidator.java	Fri Nov 15 09:34:41 2013 +0100
@@ -11,6 +11,7 @@
 
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.datatype.joda.JodaModule;
 
 @Component
 public class SpaceFormValidator implements Validator {
@@ -32,6 +33,8 @@
         if (space.getBinConfig() != null && space.getBinConfig().length() > 0) {
             boolean valid = false;
             ObjectMapper mapper = new ObjectMapper();
+            mapper.registerModule(new JodaModule());
+            
             try {
                 mapper.readTree(space.getBinConfig());
                 valid = true;
--- a/server/src/main/java/org/iri_research/renkan/forms/UserForm.java	Thu Nov 07 10:42:18 2013 +0100
+++ b/server/src/main/java/org/iri_research/renkan/forms/UserForm.java	Fri Nov 15 09:34:41 2013 +0100
@@ -1,22 +1,26 @@
 package org.iri_research.renkan.forms;
 
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.List;
 
 import org.iri_research.renkan.Constants;
 import org.iri_research.renkan.models.User;
 import org.iri_research.renkan.repositories.IRenkanRepository;
 import org.iri_research.renkan.repositories.UsersRepository;
+import org.joda.time.DateTime;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.springframework.format.annotation.DateTimeFormat.ISO;
 import org.springframework.security.crypto.password.PasswordEncoder;
 
 public class UserForm extends RenkanForm<String, User> {
 
     private String avatar;
 
-    private Date credentialExpirationDate;
-    private Date expirationDate;
+    @DateTimeFormat(iso = ISO.DATE)
+    private DateTime credentialExpirationDate;
+    @DateTimeFormat(iso = ISO.DATE)
+    private DateTime expirationDate;
 
     private String email;
 
@@ -56,7 +60,7 @@
         return avatar;
     }
 
-    public Date getCredentialExpirationDate() {
+    public DateTime getCredentialExpirationDate() {
         return credentialExpirationDate;
     }
 
@@ -64,7 +68,7 @@
         return email;
     }
 
-    public Date getExpirationDate() {
+    public DateTime getExpirationDate() {
         return expirationDate;
     }
 
@@ -120,7 +124,7 @@
         this.avatar = avatar;
     }
 
-    public void setCredentialExpirationDate(Date credentialExpirationDate) {
+    public void setCredentialExpirationDate(DateTime credentialExpirationDate) {
         this.credentialExpirationDate = credentialExpirationDate;
     }
 
@@ -132,7 +136,7 @@
         this.enabled = enabled;
     }
 
-    public void setExpirationDate(Date expirationDate) {
+    public void setExpirationDate(DateTime expirationDate) {
         this.expirationDate = expirationDate;
     }
 
--- a/server/src/main/java/org/iri_research/renkan/forms/UserFormValidator.java	Thu Nov 07 10:42:18 2013 +0100
+++ b/server/src/main/java/org/iri_research/renkan/forms/UserFormValidator.java	Fri Nov 15 09:34:41 2013 +0100
@@ -39,7 +39,7 @@
             errors.rejectValue("password", "renkan.error.password.missing");
         }
         
-        if(!Constants.USER_ROLES_ALL.containsAll(userForm.getUserAuthorities())) {
+        if(userForm.getUserAuthorities() != null && !Constants.USER_ROLES_ALL.containsAll(userForm.getUserAuthorities())) {
             errors.rejectValue("userAuthorities", "renkan.error.authorities.bad_value", "Bad role value");
         }
     }
--- a/server/src/main/java/org/iri_research/renkan/models/Project.java	Thu Nov 07 10:42:18 2013 +0100
+++ b/server/src/main/java/org/iri_research/renkan/models/Project.java	Fri Nov 15 09:34:41 2013 +0100
@@ -4,7 +4,6 @@
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -16,6 +15,7 @@
 import org.iri_research.renkan.Constants.EditMode;
 import org.iri_research.renkan.RenkanException;
 import org.iri_research.renkan.utils.ColorGenerator;
+import org.joda.time.DateTime;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -36,9 +36,9 @@
     private int revCounter = 1;
 
     @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone = "GMT")
-    private Date created;
+    private DateTime created;
     @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone = "GMT")
-    private Date updated;
+    private DateTime updated;
 
     // Space
     @Field("space_id")
@@ -58,7 +58,7 @@
 
     public Project(Project project) {
         this(project.spaceId, Constants.UUID_GENERATOR.generate().toString(),
-                project.title, project.description, project.uri, new Date());
+                project.title, project.description, project.uri, new DateTime());
 
         Map<String, Node> nodeCloneMap = new HashMap<String, Node>(
                 project.nodes.size());
@@ -78,20 +78,20 @@
     }
 
     public Project(String spaceId, String id, String title, String description,
-            String uri, Date created, int revCounter) {
+            String uri, DateTime created, int revCounter) {
         super(id, title, description, uri, null);
         this.revCounter = revCounter;
         this.spaceId = spaceId;
         this.created = created;
         if (this.created == null) {
-            this.created = new Date();
+            this.created = new DateTime();
         }
-        this.setUpdated(new Date());
+        this.setUpdated(new DateTime());
     }
 
     @Autowired(required = true)
     public Project(String spaceId, String id, String title, String description,
-            String uri, Date created) {
+            String uri, DateTime created) {
         this(spaceId, id, title, description, uri, created, 1);
     }
 
@@ -116,11 +116,11 @@
     }
 
     @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone = "GMT")
-    public Date getCreated() {
+    public DateTime getCreated() {
         return created;
     }
 
-    public void setCreated(Date date) {
+    public void setCreated(DateTime date) {
         this.created = date;
 
     }
@@ -136,7 +136,7 @@
         key.append('|');
         key.append(this.getSpaceId());
         key.append('|');
-        key.append(this.getCreated().getTime());
+        key.append(this.getCreated().getMillis());
         key.append('|');
         key.append(editMode.toString());
         return key.toString();
@@ -186,11 +186,11 @@
     }
 
     @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone = "GMT")
-    public Date getUpdated() {
+    public DateTime getUpdated() {
         return updated;
     }
 
-    public void setUpdated(Date updated) {
+    public void setUpdated(DateTime updated) {
         this.updated = updated;
     }
 
@@ -256,7 +256,7 @@
 
     @Override
     protected String getRawKeyPart() {
-        return Long.toString(this.getCreated().getTime());
+        return Long.toString(this.getCreated().getMillis());
     }
 
 }
--- a/server/src/main/java/org/iri_research/renkan/models/ProjectRevision.java	Thu Nov 07 10:42:18 2013 +0100
+++ b/server/src/main/java/org/iri_research/renkan/models/ProjectRevision.java	Fri Nov 15 09:34:41 2013 +0100
@@ -5,6 +5,7 @@
 import java.util.List;
 
 import org.bson.types.ObjectId;
+import org.joda.time.DateTime;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.data.mongodb.core.mapping.DBRef;
@@ -25,7 +26,7 @@
     private Project project;
 
     @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone = "GMT")
-    private Date created;
+    private DateTime created;
 
     // Nodes
     private List<Node> nodes = new ArrayList<Node>();
@@ -49,7 +50,7 @@
         this.project = project;
         this.revision = revision;
         if (created == null) {
-            this.created = new Date(System.currentTimeMillis());
+            this.created = new DateTime(System.currentTimeMillis());
         }
     }
 
@@ -70,13 +71,13 @@
     }
 
     @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone = "GMT")
-    public Date getCreated() {
+    public DateTime getCreated() {
         return created;
     }
 
     @Override
     protected String getRawKeyPart() {
-        return Long.toString(this.getCreated().getTime());
+        return Long.toString(this.getCreated().getMillis());
     }
 
 }
--- a/server/src/main/java/org/iri_research/renkan/models/ProjectSync.java	Thu Nov 07 10:42:18 2013 +0100
+++ b/server/src/main/java/org/iri_research/renkan/models/ProjectSync.java	Fri Nov 15 09:34:41 2013 +0100
@@ -1,8 +1,7 @@
 package org.iri_research.renkan.models;
 
-import java.util.Date;
-
 import org.bson.types.ObjectId;
+import org.joda.time.DateTime;
 import org.springframework.data.mongodb.core.mapping.DBRef;
 import org.springframework.data.mongodb.core.mapping.Document;
 
@@ -21,12 +20,12 @@
     private int revision;
 
     @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone = "GMT")
-    private Date created;
+    private DateTime created;
 
     private String user;
 
     public ProjectSync(ObjectId id, String data, Project project, int revision,
-            Date created, String user) {
+            DateTime created, String user) {
         this.id = id;
         this.data = data;
         this.project = project;
@@ -34,7 +33,7 @@
         this.created = created;
         this.user = user;
         if (this.created == null) {
-            this.created = new Date(System.currentTimeMillis());
+            this.created = new DateTime(System.currentTimeMillis());
         }
     }
 
--- a/server/src/main/java/org/iri_research/renkan/models/Space.java	Thu Nov 07 10:42:18 2013 +0100
+++ b/server/src/main/java/org/iri_research/renkan/models/Space.java	Fri Nov 15 09:34:41 2013 +0100
@@ -1,7 +1,6 @@
 package org.iri_research.renkan.models;
 
-import java.util.Date;
-
+import org.joda.time.DateTime;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.mongodb.core.mapping.Document;
 import org.springframework.data.mongodb.core.mapping.Field;
@@ -15,7 +14,7 @@
     @Autowired
     public Space(String id, String title, String description, String binConfig,
             String uri, String color, String createdBy, String image,
-            Date created) {
+            DateTime created) {
         super(id, title, description, uri, color);
 
         this.binConfig = binConfig;
@@ -23,7 +22,7 @@
         this.setImage(image);
         this.created = created;
         if (this.created == null) {
-            this.created = new Date();
+            this.created = new DateTime();
         }
     }
 
@@ -40,7 +39,7 @@
     private String image;
 
     @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone = "GMT")
-    private Date created;
+    private DateTime created;
 
     public String getImage() {
         return image;
@@ -52,11 +51,11 @@
     }
 
     @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone = "GMT")
-    public Date getCreated() {
+    public DateTime getCreated() {
         return created;
     }
 
-    public void setCreated(Date date) {
+    public void setCreated(DateTime date) {
         this.created = date;
 
     }
@@ -77,7 +76,7 @@
 
     @Override
     protected String getRawKeyPart() {
-        return Long.toString(this.getCreated().getTime());
+        return Long.toString(this.getCreated().getMillis());
     }
 
 }
\ No newline at end of file
--- a/server/src/main/java/org/iri_research/renkan/models/User.java	Thu Nov 07 10:42:18 2013 +0100
+++ b/server/src/main/java/org/iri_research/renkan/models/User.java	Fri Nov 15 09:34:41 2013 +0100
@@ -2,10 +2,10 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Date;
 import java.util.List;
 
 import org.iri_research.renkan.Constants;
+import org.joda.time.DateTime;
 import org.springframework.data.mongodb.core.mapping.Document;
 import org.springframework.data.mongodb.core.mapping.Field;
 import org.springframework.security.core.GrantedAuthority;
@@ -24,12 +24,12 @@
     private String avatar;
     @Field("credentials_expiration_date")
     @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone = "GMT")
-    private Date credentialExpirationDate;
+    private DateTime credentialExpirationDate;
     private String email;
     private boolean enabled;
     @Field("expiration_date")
     @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone = "GMT")
-    private Date expirationDate;
+    private DateTime expirationDate;
     private boolean locked;
     private String password;
     @Field("authorities")
@@ -66,7 +66,7 @@
         return this.color;
     }
 
-    public Date getCredentialExpirationDate() {
+    public DateTime getCredentialExpirationDate() {
         return credentialExpirationDate;
     }
 
@@ -74,7 +74,7 @@
         return email;
     }
 
-    public Date getExpirationDate() {
+    public DateTime getExpirationDate() {
         return expirationDate;
     }
 
@@ -102,7 +102,7 @@
     @Override
     public boolean isAccountNonExpired() {
         return this.expirationDate == null
-                || this.expirationDate.after(new Date());
+                || this.expirationDate.isAfterNow();
     }
 
     @Override
@@ -113,7 +113,7 @@
     @Override
     public boolean isCredentialsNonExpired() {
         return this.credentialExpirationDate == null
-                || this.credentialExpirationDate.after(new Date());
+                || this.credentialExpirationDate.isAfterNow();
     }
 
     @Override
@@ -129,7 +129,7 @@
         this.avatar = avatar;
     }
 
-    public void setCredentialExpirationDate(Date credentialExpirationDate) {
+    public void setCredentialExpirationDate(DateTime credentialExpirationDate) {
         this.credentialExpirationDate = credentialExpirationDate;
     }
 
@@ -141,7 +141,7 @@
         this.enabled = enabled;
     }
 
-    public void setExpirationDate(Date expirationDate) {
+    public void setExpirationDate(DateTime expirationDate) {
         this.expirationDate = expirationDate;
     }
 
--- a/server/src/main/java/org/iri_research/renkan/repositories/ProjectSyncsRepositoryImpl.java	Thu Nov 07 10:42:18 2013 +0100
+++ b/server/src/main/java/org/iri_research/renkan/repositories/ProjectSyncsRepositoryImpl.java	Fri Nov 15 09:34:41 2013 +0100
@@ -1,10 +1,9 @@
 package org.iri_research.renkan.repositories;
 
-import java.util.Date;
-
 import org.iri_research.renkan.RenkanException;
 import org.iri_research.renkan.models.Project;
 import org.iri_research.renkan.models.ProjectSync;
+import org.joda.time.DateTime;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -24,7 +23,7 @@
 
         ProjectSync ps = new ProjectSync(null, data, project,
                 this.projectRepository.getRevCounter(project.getId()),
-                new Date(System.currentTimeMillis()), user);
+                new DateTime(), user);
 
         return ps;
     }
--- a/server/src/main/java/org/iri_research/renkan/rest/ObjectMapperProvider.java	Thu Nov 07 10:42:18 2013 +0100
+++ b/server/src/main/java/org/iri_research/renkan/rest/ObjectMapperProvider.java	Fri Nov 15 09:34:41 2013 +0100
@@ -7,6 +7,7 @@
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.datatype.joda.JodaModule;
 
 @Component
 @Provider
@@ -17,6 +18,7 @@
         ObjectMapper objectMapper = new ObjectMapper();
         objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS,
                 false);
+        objectMapper.registerModule(new JodaModule());
 
         return objectMapper;
     }
--- a/server/src/main/java/org/iri_research/renkan/rest/ProjectsResource.java	Thu Nov 07 10:42:18 2013 +0100
+++ b/server/src/main/java/org/iri_research/renkan/rest/ProjectsResource.java	Fri Nov 15 09:34:41 2013 +0100
@@ -1,7 +1,6 @@
 package org.iri_research.renkan.rest;
 
 import java.util.Arrays;
-import java.util.Date;
 import java.util.List;
 
 import javax.inject.Singleton;
@@ -11,6 +10,7 @@
 import org.iri_research.renkan.models.Project;
 import org.iri_research.renkan.repositories.IRenkanRepository;
 import org.iri_research.renkan.repositories.ProjectsRepository;
+import org.joda.time.DateTime;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -40,9 +40,9 @@
     @Override
     protected void prepareObject(Project obj) {
         if (obj.getCreated() == null) {
-            obj.setCreated(new Date());
+            obj.setCreated(new DateTime());
         }
-        obj.setUpdated(new Date());
+        obj.setUpdated(new DateTime());
     }
 
     @Override
--- a/server/src/main/java/org/iri_research/renkan/rest/RenkanResource.java	Thu Nov 07 10:42:18 2013 +0100
+++ b/server/src/main/java/org/iri_research/renkan/rest/RenkanResource.java	Fri Nov 15 09:34:41 2013 +0100
@@ -28,6 +28,7 @@
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.datatype.joda.JodaModule;
 import com.mongodb.BasicDBObject;
 import com.mongodb.DBCollection;
 import com.mongodb.DBCursor;
@@ -205,6 +206,7 @@
         }
         ObjectMapper mapper = new ObjectMapper();
         mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
+        mapper.registerModule(new JodaModule());
         return mapper.writeValueAsString(res);
     }
 
--- a/server/src/main/java/org/iri_research/renkan/rest/RestApplication.java	Thu Nov 07 10:42:18 2013 +0100
+++ b/server/src/main/java/org/iri_research/renkan/rest/RestApplication.java	Fri Nov 15 09:34:41 2013 +0100
@@ -4,10 +4,25 @@
 import org.glassfish.jersey.server.spring.SpringLifecycleListener;
 import org.glassfish.jersey.server.spring.scope.RequestContextFilter;
 
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.datatype.joda.JodaModule;
+import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
+
 public class RestApplication extends ResourceConfig {
     public RestApplication() {
+
         this.packages("org.iri_research.renkan.rest");
         this.register(SpringLifecycleListener.class);
         this.register(RequestContextFilter.class);
+        
+        ObjectMapper objectMapper = new ObjectMapper();
+        objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS,
+                false);
+        objectMapper.registerModule(new JodaModule());
+        JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider(objectMapper, JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS);
+        
+        this.register(provider);
+        
     }
 }
--- a/server/src/main/java/org/iri_research/renkan/rest/SpacesResource.java	Thu Nov 07 10:42:18 2013 +0100
+++ b/server/src/main/java/org/iri_research/renkan/rest/SpacesResource.java	Fri Nov 15 09:34:41 2013 +0100
@@ -2,7 +2,6 @@
 
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Date;
 import java.util.List;
 
 import javax.inject.Singleton;
@@ -12,6 +11,7 @@
 import org.iri_research.renkan.models.Space;
 import org.iri_research.renkan.repositories.IRenkanRepository;
 import org.iri_research.renkan.repositories.SpacesRepository;
+import org.joda.time.DateTime;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -44,7 +44,7 @@
     @Override
     protected void prepareObject(Space obj) {
         if (obj.getCreated() == null) {
-            obj.setCreated(new Date());
+            obj.setCreated(new DateTime());
         }
     }
 
--- a/server/src/main/webapp/WEB-INF/applicationContext.xml	Thu Nov 07 10:42:18 2013 +0100
+++ b/server/src/main/webapp/WEB-INF/applicationContext.xml	Fri Nov 15 09:34:41 2013 +0100
@@ -90,7 +90,7 @@
             </list>
         </property>
         <property name="defaultEncoding" value="UTF-8"/>
-        <property name="fallbackToSystemLocale" value="true" />       
+        <property name="fallbackToSystemLocale" value="true" />
     </bean>
     
 
--- a/server/src/test/java/org/iri_research/renkan/test/controller/AdminControllerTest.java	Thu Nov 07 10:42:18 2013 +0100
+++ b/server/src/test/java/org/iri_research/renkan/test/controller/AdminControllerTest.java	Fri Nov 15 09:34:41 2013 +0100
@@ -1,27 +1,24 @@
 package org.iri_research.renkan.test.controller;
 
-import java.security.SecureRandom;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.TimeZone;
 import java.util.UUID;
 
-import org.apache.commons.codec.binary.Hex;
 import org.iri_research.renkan.models.Project;
 import org.iri_research.renkan.models.Space;
 import org.iri_research.renkan.repositories.ProjectsRepository;
 import org.iri_research.renkan.repositories.SpacesRepository;
+import org.joda.time.DateTime;
 import org.junit.After;
-import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.test.context.web.WebAppConfiguration;
@@ -31,9 +28,7 @@
 import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
 import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
 import org.springframework.test.web.servlet.setup.MockMvcBuilders;
-import org.springframework.web.client.HttpClientErrorException;
 import org.springframework.web.context.WebApplicationContext;
-import org.springframework.web.util.NestedServletException;
 
 @RunWith(SpringJUnit4ClassRunner.class)
 @WebAppConfiguration
@@ -63,12 +58,13 @@
     public void setup() {
 
         logger.debug("Setup");
+        TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
         spacesRepository.deleteAll();
         projectsRepository.deleteAll();
 
         ArrayList<Project> pl = new ArrayList<Project>();
         for (int i = 0; i < SPACE_NB; i++) {
-            Date creationDate = new Date();
+            DateTime creationDate = new DateTime();
             String uuid = UUID.randomUUID().toString();
             spacesUuids.add(uuid);
             Space testSpace = new Space(uuid, "test " + i, "Test space " + 1,
@@ -115,452 +111,4 @@
 
     }
 
-    @Test
-    public void testSpacePostUpdate() throws Exception {
-
-        MockHttpServletRequestBuilder post = MockMvcRequestBuilders
-                .post("/admin/spaces/save");
-        post = post.param("id", this.spacesUuids.get(0));
-        post = post.param("title", "New title");
-        post = post.param("description", "New description");
-        post = post.param("uri", "http://ldt.iri.centrepompidou.fr/new/uri");
-        post = post.param("color", "#ffffff");
-        post = post.param("binConfig", "{}");
-
-        this.mvc.perform(post)
-                .andExpect(MockMvcResultMatchers.status().isSeeOther())
-                .andExpect(MockMvcResultMatchers.redirectedUrl("/admin/spaces"));
-
-        Space sp = this.spacesRepository.findOne(this.spacesUuids.get(0));
-
-        Assert.assertNotNull("Should find space", sp);
-        Assert.assertEquals("Title equals", "New title", sp.getTitle());
-        Assert.assertEquals("Description equals", "New description",
-                sp.getDescription());
-        Assert.assertEquals("Uri equals",
-                "http://ldt.iri.centrepompidou.fr/new/uri", sp.getUri());
-        Assert.assertEquals("Color equals", "#ffffff", sp.getColor());
-        Assert.assertEquals("BinConfig equals", "{}", sp.getBinConfig());
-
-    }
-
-    @Test
-    public void testSpacePostCreate() throws Exception {
-
-        MockHttpServletRequestBuilder post = MockMvcRequestBuilders
-                .post("/admin/spaces/save");
-        post = post.param("title", "New title");
-        post = post.param("description", "New description");
-        post = post.param("uri", "http://ldt.iri.centrepompidou.fr/new/uri");
-        post = post.param("color", "#ffffff");
-        post = post.param("binConfig", "{}");
-
-        this.mvc.perform(post)
-                .andExpect(MockMvcResultMatchers.status().isSeeOther())
-                .andExpect(MockMvcResultMatchers.redirectedUrl("/admin/spaces"));
-
-        Assert.assertEquals("Must have one more space", SPACE_NB + 1,
-                this.spacesRepository.count());
-
-        for (Space sp : this.spacesRepository.findAll()) {
-            if (this.spacesList.containsKey(sp.getId())) {
-                continue;
-            } else {
-                Assert.assertNotNull("Should find space", sp);
-                Assert.assertEquals("Title equals", "New title", sp.getTitle());
-                Assert.assertEquals("Description equals", "New description",
-                        sp.getDescription());
-                Assert.assertEquals("Uri equals",
-                        "http://ldt.iri.centrepompidou.fr/new/uri", sp.getUri());
-                Assert.assertEquals("Color equals", "#ffffff", sp.getColor());
-                Assert.assertEquals("BinConfig equals", "{}", sp.getBinConfig());
-                Assert.assertTrue(
-                        "id sould match uuid regex",
-                        sp.getId()
-                                .matches(
-                                        "[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}"));
-                Assert.assertNotNull("Date created should be not null",
-                        sp.getCreated());
-            }
-        }
-    }
-
-    @Test
-    public void testSpacePostUpdateEmptyTitle() throws Exception {
-
-        MockHttpServletRequestBuilder post = MockMvcRequestBuilders
-                .post("/admin/spaces/save");
-        post = post.param("id", this.spacesUuids.get(0));
-        post = post.param("title", "");
-        post = post.param("description", "New description");
-        post = post.param("uri", "http://ldt.iri.centrepompidou.fr/new/uri");
-        post = post.param("color", "#ffffff");
-        post = post.param("binConfig", "{}");
-
-        this.mvc.perform(post)
-                .andExpect(MockMvcResultMatchers.status().isOk())
-                .andExpect(MockMvcResultMatchers.view().name("admin/spaceEdit"))
-                .andExpect(MockMvcResultMatchers.model().hasErrors())
-                .andExpect(MockMvcResultMatchers.model().errorCount(1))
-                .andExpect(
-                        MockMvcResultMatchers.model().attributeHasErrors(
-                                "space"))
-                .andExpect(
-                        MockMvcResultMatchers.model().attributeHasFieldErrors(
-                                "space", "title"));
-
-        Space sp = this.spacesRepository.findOne(this.spacesUuids.get(0));
-
-        Assert.assertNotNull("Should find space", sp);
-        Assert.assertEquals("Title equals", "test 0", sp.getTitle());
-
-    }
-
-    @Test
-    public void testSpacePostCreateEmptyTitle() throws Exception {
-
-        MockHttpServletRequestBuilder post = MockMvcRequestBuilders
-                .post("/admin/spaces/save");
-        post = post.param("title", "");
-        post = post.param("description", "New description");
-        post = post.param("uri", "http://ldt.iri.centrepompidou.fr/new/uri");
-        post = post.param("color", "#ffffff");
-        post = post.param("binConfig", "{}");
-
-        this.mvc.perform(post)
-                .andExpect(MockMvcResultMatchers.status().isOk())
-                .andExpect(MockMvcResultMatchers.view().name("admin/spaceEdit"))
-                .andExpect(MockMvcResultMatchers.model().hasErrors())
-                .andExpect(MockMvcResultMatchers.model().errorCount(1))
-                .andExpect(
-                        MockMvcResultMatchers.model().attributeHasErrors(
-                                "space"))
-                .andExpect(
-                        MockMvcResultMatchers.model().attributeHasFieldErrors(
-                                "space", "title"));
-
-        Assert.assertEquals("Must not have one more space", SPACE_NB,
-                this.spacesRepository.count());
-
-    }
-
-    @Test
-    public void testSpacePostUpdateBadJson() throws Exception {
-
-        MockHttpServletRequestBuilder post = MockMvcRequestBuilders
-                .post("/admin/spaces/save");
-        post = post.param("id", this.spacesUuids.get(0));
-        post = post.param("title", "New Title");
-        post = post.param("description", "New description");
-        post = post.param("uri", "http://ldt.iri.centrepompidou.fr/new/uri");
-        post = post.param("color", "#ffffff");
-        post = post.param("binConfig", "{");
-
-        this.mvc.perform(post)
-                .andExpect(MockMvcResultMatchers.status().isOk())
-                .andExpect(MockMvcResultMatchers.view().name("admin/spaceEdit"))
-                .andExpect(MockMvcResultMatchers.model().hasErrors())
-                .andExpect(MockMvcResultMatchers.model().errorCount(1))
-                .andExpect(
-                        MockMvcResultMatchers.model().attributeHasErrors(
-                                "space"))
-                .andExpect(
-                        MockMvcResultMatchers.model().attributeHasFieldErrors(
-                                "space", "binConfig"));
-
-        Space sp = this.spacesRepository.findOne(this.spacesUuids.get(0));
-
-        Assert.assertNotNull("Should find space", sp);
-        Assert.assertEquals("Bin config equals", "{}", sp.getBinConfig());
-
-    }
-
-    @Test
-    public void testSpacePostCreateBadJson() throws Exception {
-
-        MockHttpServletRequestBuilder post = MockMvcRequestBuilders
-                .post("/admin/spaces/save");
-        post = post.param("title", "New Title");
-        post = post.param("description", "New description");
-        post = post.param("uri", "http://ldt.iri.centrepompidou.fr/new/uri");
-        post = post.param("color", "#ffffff");
-        post = post.param("binConfig", "}");
-
-        this.mvc.perform(post)
-                .andExpect(MockMvcResultMatchers.status().isOk())
-                .andExpect(MockMvcResultMatchers.view().name("admin/spaceEdit"))
-                .andExpect(MockMvcResultMatchers.model().hasErrors())
-                .andExpect(MockMvcResultMatchers.model().errorCount(1))
-                .andExpect(
-                        MockMvcResultMatchers.model().attributeHasErrors(
-                                "space"))
-                .andExpect(
-                        MockMvcResultMatchers.model().attributeHasFieldErrors(
-                                "space", "binConfig"));
-
-        Assert.assertEquals("Must not have one more space", SPACE_NB,
-                this.spacesRepository.count());
-
-    }
-
-    @Test
-    public void testSpacePostUpdateAllErrors() throws Exception {
-
-        MockHttpServletRequestBuilder post = MockMvcRequestBuilders
-                .post("/admin/spaces/save");
-        post = post.param("id", this.spacesUuids.get(0));
-        post = post.param("title", "");
-        post = post.param("description", "New description");
-        post = post.param("uri", "http://ldt.iri.centrepompidou.fr/new/uri");
-        post = post.param("color", "#ffffff");
-        post = post.param("binConfig", "{");
-
-        this.mvc.perform(post)
-                .andExpect(MockMvcResultMatchers.status().isOk())
-                .andExpect(MockMvcResultMatchers.view().name("admin/spaceEdit"))
-                .andExpect(MockMvcResultMatchers.model().hasErrors())
-                .andExpect(MockMvcResultMatchers.model().errorCount(2))
-                .andExpect(
-                        MockMvcResultMatchers.model().attributeHasErrors(
-                                "space"))
-                .andExpect(
-                        MockMvcResultMatchers.model().attributeHasFieldErrors(
-                                "space", "title"))
-                .andExpect(
-                        MockMvcResultMatchers.model().attributeHasFieldErrors(
-                                "space", "binConfig"));
-
-        Space sp = this.spacesRepository.findOne(this.spacesUuids.get(0));
-
-        Assert.assertNotNull("Should find space", sp);
-        Assert.assertEquals("Bin config equals", "{}", sp.getBinConfig());
-        Assert.assertEquals("title equals", "test 0", sp.getTitle());
-
-    }
-
-    @Test
-    public void testSpacePostCreateAllErrors() throws Exception {
-
-        MockHttpServletRequestBuilder post = MockMvcRequestBuilders
-                .post("/admin/spaces/save");
-        post = post.param("title", "");
-        post = post.param("description", "New description");
-        post = post.param("uri", "http://ldt.iri.centrepompidou.fr/new/uri");
-        post = post.param("color", "#ffffff");
-        post = post.param("binConfig", "}");
-
-        this.mvc.perform(post)
-                .andExpect(MockMvcResultMatchers.status().isOk())
-                .andExpect(MockMvcResultMatchers.view().name("admin/spaceEdit"))
-                .andExpect(MockMvcResultMatchers.model().hasErrors())
-                .andExpect(MockMvcResultMatchers.model().errorCount(2))
-                .andExpect(
-                        MockMvcResultMatchers.model().attributeHasErrors(
-                                "space"))
-                .andExpect(
-                        MockMvcResultMatchers.model().attributeHasFieldErrors(
-                                "space", "title"))
-                .andExpect(
-                        MockMvcResultMatchers.model().attributeHasFieldErrors(
-                                "space", "binConfig"));
-
-        Assert.assertEquals("Must not have one more space", SPACE_NB,
-                this.spacesRepository.count());
-
-    }
-
-    @Test
-    public void testDeleteSpace() throws Exception {
-
-        MockHttpServletRequestBuilder get = MockMvcRequestBuilders
-                .get("/admin/spaces/delete/"
-                        + this.spacesUuids.get(SPACE_NB - 1));
-
-        MvcResult res = this.mvc
-                .perform(get)
-                .andExpect(MockMvcResultMatchers.status().isOk())
-                .andExpect(
-                        MockMvcResultMatchers.view().name(
-                                "admin/spaceDeleteConfirm"))
-                .andExpect(
-                        MockMvcResultMatchers.model().attributeExists(
-                                "spaceObj", "key", "salt")).andReturn();
-
-        Map<String, Object> model = res.getModelAndView().getModel();
-
-        Space space = (Space) model.get("spaceObj");
-        Assert.assertNotNull("Space is not null", space);
-        Assert.assertEquals("Must be first space id",
-                this.spacesUuids.get(SPACE_NB - 1), space.getId());
-
-        String key = (String) model.get("key");
-        Assert.assertNotNull("key is not null", key);
-
-        String salt = (String) model.get("salt");
-        Assert.assertNotNull("salt is not null", salt);
-
-        Assert.assertTrue("Key must be checked", space.checkKey(key, salt));
-
-    }
-
-    @Test
-    public void testDeleteFakeSpace() throws Exception {
-
-        MockHttpServletRequestBuilder get = MockMvcRequestBuilders
-                .get("/admin/spaces/delete/" + UUID.randomUUID().toString());
-
-        try {
-            this.mvc.perform(get).andExpect(
-                    MockMvcResultMatchers.status().isNotFound());
-        } catch (NestedServletException e) {
-            Assert.assertNotNull("Nested exception must not be null",
-                    e.getCause());
-            Assert.assertEquals(
-                    "Inner exception must be a HttpClientErrorException",
-                    HttpClientErrorException.class, e.getCause().getClass());
-            Assert.assertEquals("Exception error status must be not found",
-                    HttpStatus.NOT_FOUND,
-                    ((HttpClientErrorException) e.getCause()).getStatusCode());
-        }
-
-    }
-
-    @Test
-    public void testDeleteSpaceProject() throws Exception {
-
-        MockHttpServletRequestBuilder get = MockMvcRequestBuilders
-                .get("/admin/spaces/delete/" + this.spacesUuids.get(0));
-
-        try {
-            this.mvc.perform(get).andExpect(
-                    MockMvcResultMatchers.status().isBadRequest());
-        } catch (NestedServletException e) {
-            Assert.assertNotNull("Nested exception must not be null",
-                    e.getCause());
-            Assert.assertEquals(
-                    "Inner exception must be a HttpClientErrorException",
-                    HttpClientErrorException.class, e.getCause().getClass());
-            Assert.assertEquals("Exception error status must be not found",
-                    HttpStatus.BAD_REQUEST,
-                    ((HttpClientErrorException) e.getCause()).getStatusCode());
-        }
-
-    }
-
-    @Test
-    public void testDoDeleteSpaceNoKey() throws Exception {
-        MockHttpServletRequestBuilder post = MockMvcRequestBuilders
-                .post("/admin/spaces/delete/"
-                        + this.spacesUuids.get(SPACE_NB - 1));
-
-        try {
-            this.mvc.perform(post).andExpect(
-                    MockMvcResultMatchers.status().isBadRequest());
-        } catch (NestedServletException e) {
-            Assert.assertNotNull("Nested exception must not be null",
-                    e.getCause());
-            Assert.assertEquals(
-                    "Inner exception must be a HttpClientErrorException",
-                    HttpClientErrorException.class, e.getCause().getClass());
-            Assert.assertEquals("Exception error status must be not found",
-                    HttpStatus.BAD_REQUEST,
-                    ((HttpClientErrorException) e.getCause()).getStatusCode());
-        }
-
-        Assert.assertEquals("Must have same nb of space", SPACE_NB,
-                this.spacesRepository.count());
-
-    }
-
-    @Test
-    public void testDoDeleteSpace() throws Exception {
-
-        Space space = this.spacesList.get(this.spacesUuids.get(SPACE_NB - 1));
-
-        SecureRandom rand = SecureRandom.getInstance("SHA1PRNG");
-        rand.setSeed(System.currentTimeMillis());
-        byte[] rawSalt = new byte[50];
-        rand.nextBytes(rawSalt);
-        String salt = Hex.encodeHexString(rawSalt);
-        String key = space.getKey(salt);
-
-        MockHttpServletRequestBuilder post = MockMvcRequestBuilders.post(String
-                .format("/admin/spaces/delete/%s?key=%s&salt=%s",
-                        this.spacesUuids.get(SPACE_NB - 1), key, salt));
-
-        this.mvc.perform(post)
-                .andExpect(MockMvcResultMatchers.status().isSeeOther())
-                .andExpect(MockMvcResultMatchers.redirectedUrl("/admin/spaces"));
-
-        Assert.assertEquals("Must have one less space", SPACE_NB - 1,
-                this.spacesRepository.count());
-
-        space = this.spacesRepository.findOne(this.spacesUuids
-                .get(SPACE_NB - 1));
-
-        Assert.assertNull("Space " + this.spacesUuids.get(SPACE_NB - 1)
-                + " deleted", space);
-
-    }
-
-    @Test
-    public void testDoDeleteSpaceFake() throws Exception {
-
-        Space space = this.spacesList.get(this.spacesUuids.get(SPACE_NB - 1));
-
-        SecureRandom rand = SecureRandom.getInstance("SHA1PRNG");
-        rand.setSeed(System.currentTimeMillis());
-        byte[] rawSalt = new byte[50];
-        rand.nextBytes(rawSalt);
-        String salt = Hex.encodeHexString(rawSalt);
-        String key = space.getKey(salt);
-
-        MockHttpServletRequestBuilder post = MockMvcRequestBuilders.post(String
-                .format("/admin/spaces/delete/%s?key=%s&salt=%s",
-                        UUID.randomUUID(), key, salt));
-
-        this.mvc.perform(post)
-                .andExpect(MockMvcResultMatchers.status().isSeeOther())
-                .andExpect(MockMvcResultMatchers.redirectedUrl("/admin/spaces"));
-
-        Assert.assertEquals("Must have the same nb of space", SPACE_NB,
-                this.spacesRepository.count());
-
-    }
-
-    @Test
-    public void testDoDeleteSpaceProject() throws Exception {
-
-        Space space = this.spacesList.get(this.spacesUuids.get(0));
-
-        SecureRandom rand = SecureRandom.getInstance("SHA1PRNG");
-        rand.setSeed(System.currentTimeMillis());
-        byte[] rawSalt = new byte[50];
-        rand.nextBytes(rawSalt);
-        String salt = Hex.encodeHexString(rawSalt);
-        String key = space.getKey(salt);
-
-        MockHttpServletRequestBuilder post = MockMvcRequestBuilders.post(String
-                .format("/admin/spaces/delete/%s?key=%s&salt=%s",
-                        this.spacesUuids.get(0), key, salt));
-
-        try {
-            this.mvc.perform(post).andExpect(
-                    MockMvcResultMatchers.status().isBadRequest());
-        } catch (NestedServletException e) {
-            Assert.assertNotNull("Nested exception must not be null",
-                    e.getCause());
-            Assert.assertEquals(
-                    "Inner exception must be a HttpClientErrorException",
-                    HttpClientErrorException.class, e.getCause().getClass());
-            Assert.assertEquals("Exception error status must be not found",
-                    HttpStatus.BAD_REQUEST,
-                    ((HttpClientErrorException) e.getCause()).getStatusCode());
-        }
-
-        Assert.assertEquals("Must have the same nb of space", SPACE_NB,
-                this.spacesRepository.count());
-
-    }
-
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/server/src/test/java/org/iri_research/renkan/test/controller/SpacesAdminControllerTest.java	Fri Nov 15 09:34:41 2013 +0100
@@ -0,0 +1,557 @@
+package org.iri_research.renkan.test.controller;
+
+import java.security.SecureRandom;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+import java.util.UUID;
+
+import org.apache.commons.codec.binary.Hex;
+import org.iri_research.renkan.models.Project;
+import org.iri_research.renkan.models.Space;
+import org.iri_research.renkan.repositories.ProjectsRepository;
+import org.iri_research.renkan.repositories.SpacesRepository;
+import org.joda.time.DateTime;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.MvcResult;
+import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
+import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
+import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+import org.springframework.web.client.HttpClientErrorException;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.util.NestedServletException;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@WebAppConfiguration
+@ContextConfiguration(locations = { "controller-context.xml",
+        "file:src/main/webapp/WEB-INF/spring-servlet.xml" })
+public class SpacesAdminControllerTest {
+
+    private final static int SPACE_NB = 3;
+
+    private Logger logger = LoggerFactory.getLogger(SpacesAdminControllerTest.class);
+
+    @Autowired
+    private SpacesRepository spacesRepository;
+    @Autowired
+    private ProjectsRepository projectsRepository;
+
+    private Map<String, Space> spacesList = new HashMap<String, Space>(SPACE_NB);
+    private List<String> spacesUuids = new ArrayList<>(SPACE_NB);
+
+    private ArrayList<Project> testProjects = new ArrayList<Project>();
+
+    @Autowired
+    private WebApplicationContext context;
+    private MockMvc mvc;
+
+    @Before
+    public void setup() {
+
+        logger.debug("Setup");
+        TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+        spacesRepository.deleteAll();
+        projectsRepository.deleteAll();
+
+        ArrayList<Project> pl = new ArrayList<Project>();
+        for (int i = 0; i < SPACE_NB; i++) {
+            DateTime creationDate = new DateTime();
+            String uuid = UUID.randomUUID().toString();
+            spacesUuids.add(uuid);
+            Space testSpace = new Space(uuid, "test " + i, "Test space " + 1,
+                    "{}", "http://ldt.iri.centrepompidou.fr", "#ababab",
+                    "test_user", "http://ldt.iri.centrepompidou.fr",
+                    creationDate);
+            testSpace = spacesRepository.save(testSpace);
+            this.spacesList.put(uuid, testSpace);
+            for (int j = 0; j < SPACE_NB - 1 - i; j++) {
+                pl.add(new Project(testSpace.getId(), UUID.randomUUID()
+                        .toString(), "test" + ((SPACE_NB - 1) * i + j + 1),
+                        "desc" + ((SPACE_NB - 1) * i + j + 1),
+                        "http://localhost:8080/rest/projects/id"
+                                + ((SPACE_NB - 1) * i + j + 1), creationDate));
+            }
+            try {
+                Thread.sleep(1);
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+        }
+
+        for (Project p : projectsRepository.save(pl)) {
+            this.testProjects.add(p);
+        }
+
+        this.mvc = MockMvcBuilders.webAppContextSetup(this.context).build();
+    }
+
+    @After
+    public void teardown() {
+        spacesRepository.deleteAll();
+        projectsRepository.deleteAll();
+    }
+
+    @Test
+    public void testSpacePostUpdate() throws Exception {
+
+        MockHttpServletRequestBuilder post = MockMvcRequestBuilders
+                .post("/admin/spaces/save");
+        post = post.param("id", this.spacesUuids.get(0));
+        post = post.param("title", "New title");
+        post = post.param("description", "New description");
+        post = post.param("uri", "http://ldt.iri.centrepompidou.fr/new/uri");
+        post = post.param("color", "#ffffff");
+        post = post.param("binConfig", "{}");
+
+        this.mvc.perform(post)
+                .andExpect(MockMvcResultMatchers.status().isSeeOther())
+                .andExpect(MockMvcResultMatchers.redirectedUrl("/admin/spaces"));
+
+        Space sp = this.spacesRepository.findOne(this.spacesUuids.get(0));
+
+        Assert.assertNotNull("Should find space", sp);
+        Assert.assertEquals("Title equals", "New title", sp.getTitle());
+        Assert.assertEquals("Description equals", "New description",
+                sp.getDescription());
+        Assert.assertEquals("Uri equals",
+                "http://ldt.iri.centrepompidou.fr/new/uri", sp.getUri());
+        Assert.assertEquals("Color equals", "#ffffff", sp.getColor());
+        Assert.assertEquals("BinConfig equals", "{}", sp.getBinConfig());
+
+    }
+
+    @Test
+    public void testSpacePostCreate() throws Exception {
+
+        MockHttpServletRequestBuilder post = MockMvcRequestBuilders
+                .post("/admin/spaces/save");
+        post = post.param("title", "New title");
+        post = post.param("description", "New description");
+        post = post.param("uri", "http://ldt.iri.centrepompidou.fr/new/uri");
+        post = post.param("color", "#ffffff");
+        post = post.param("binConfig", "{}");
+
+        this.mvc.perform(post)
+                .andExpect(MockMvcResultMatchers.status().isSeeOther())
+                .andExpect(MockMvcResultMatchers.redirectedUrl("/admin/spaces"));
+
+        Assert.assertEquals("Must have one more space", SPACE_NB + 1,
+                this.spacesRepository.count());
+
+        for (Space sp : this.spacesRepository.findAll()) {
+            if (this.spacesList.containsKey(sp.getId())) {
+                continue;
+            } else {
+                Assert.assertNotNull("Should find space", sp);
+                Assert.assertEquals("Title equals", "New title", sp.getTitle());
+                Assert.assertEquals("Description equals", "New description",
+                        sp.getDescription());
+                Assert.assertEquals("Uri equals",
+                        "http://ldt.iri.centrepompidou.fr/new/uri", sp.getUri());
+                Assert.assertEquals("Color equals", "#ffffff", sp.getColor());
+                Assert.assertEquals("BinConfig equals", "{}", sp.getBinConfig());
+                Assert.assertTrue(
+                        "id sould match uuid regex",
+                        sp.getId()
+                                .matches(
+                                        "[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}"));
+                Assert.assertNotNull("Date created should be not null",
+                        sp.getCreated());
+            }
+        }
+    }
+
+    @Test
+    public void testSpacePostUpdateEmptyTitle() throws Exception {
+
+        MockHttpServletRequestBuilder post = MockMvcRequestBuilders
+                .post("/admin/spaces/save");
+        post = post.param("id", this.spacesUuids.get(0));
+        post = post.param("title", "");
+        post = post.param("description", "New description");
+        post = post.param("uri", "http://ldt.iri.centrepompidou.fr/new/uri");
+        post = post.param("color", "#ffffff");
+        post = post.param("binConfig", "{}");
+
+        this.mvc.perform(post)
+                .andExpect(MockMvcResultMatchers.status().isOk())
+                .andExpect(MockMvcResultMatchers.view().name("admin/spaceEdit"))
+                .andExpect(MockMvcResultMatchers.model().hasErrors())
+                .andExpect(MockMvcResultMatchers.model().errorCount(1))
+                .andExpect(
+                        MockMvcResultMatchers.model().attributeHasErrors(
+                                "space"))
+                .andExpect(
+                        MockMvcResultMatchers.model().attributeHasFieldErrors(
+                                "space", "title"));
+
+        Space sp = this.spacesRepository.findOne(this.spacesUuids.get(0));
+
+        Assert.assertNotNull("Should find space", sp);
+        Assert.assertEquals("Title equals", "test 0", sp.getTitle());
+
+    }
+
+    @Test
+    public void testSpacePostCreateEmptyTitle() throws Exception {
+
+        MockHttpServletRequestBuilder post = MockMvcRequestBuilders
+                .post("/admin/spaces/save");
+        post = post.param("title", "");
+        post = post.param("description", "New description");
+        post = post.param("uri", "http://ldt.iri.centrepompidou.fr/new/uri");
+        post = post.param("color", "#ffffff");
+        post = post.param("binConfig", "{}");
+
+        this.mvc.perform(post)
+                .andExpect(MockMvcResultMatchers.status().isOk())
+                .andExpect(MockMvcResultMatchers.view().name("admin/spaceEdit"))
+                .andExpect(MockMvcResultMatchers.model().hasErrors())
+                .andExpect(MockMvcResultMatchers.model().errorCount(1))
+                .andExpect(
+                        MockMvcResultMatchers.model().attributeHasErrors(
+                                "space"))
+                .andExpect(
+                        MockMvcResultMatchers.model().attributeHasFieldErrors(
+                                "space", "title"));
+
+        Assert.assertEquals("Must not have one more space", SPACE_NB,
+                this.spacesRepository.count());
+
+    }
+
+    @Test
+    public void testSpacePostUpdateBadJson() throws Exception {
+
+        MockHttpServletRequestBuilder post = MockMvcRequestBuilders
+                .post("/admin/spaces/save");
+        post = post.param("id", this.spacesUuids.get(0));
+        post = post.param("title", "New Title");
+        post = post.param("description", "New description");
+        post = post.param("uri", "http://ldt.iri.centrepompidou.fr/new/uri");
+        post = post.param("color", "#ffffff");
+        post = post.param("binConfig", "{");
+
+        this.mvc.perform(post)
+                .andExpect(MockMvcResultMatchers.status().isOk())
+                .andExpect(MockMvcResultMatchers.view().name("admin/spaceEdit"))
+                .andExpect(MockMvcResultMatchers.model().hasErrors())
+                .andExpect(MockMvcResultMatchers.model().errorCount(1))
+                .andExpect(
+                        MockMvcResultMatchers.model().attributeHasErrors(
+                                "space"))
+                .andExpect(
+                        MockMvcResultMatchers.model().attributeHasFieldErrors(
+                                "space", "binConfig"));
+
+        Space sp = this.spacesRepository.findOne(this.spacesUuids.get(0));
+
+        Assert.assertNotNull("Should find space", sp);
+        Assert.assertEquals("Bin config equals", "{}", sp.getBinConfig());
+
+    }
+
+    @Test
+    public void testSpacePostCreateBadJson() throws Exception {
+
+        MockHttpServletRequestBuilder post = MockMvcRequestBuilders
+                .post("/admin/spaces/save");
+        post = post.param("title", "New Title");
+        post = post.param("description", "New description");
+        post = post.param("uri", "http://ldt.iri.centrepompidou.fr/new/uri");
+        post = post.param("color", "#ffffff");
+        post = post.param("binConfig", "}");
+
+        this.mvc.perform(post)
+                .andExpect(MockMvcResultMatchers.status().isOk())
+                .andExpect(MockMvcResultMatchers.view().name("admin/spaceEdit"))
+                .andExpect(MockMvcResultMatchers.model().hasErrors())
+                .andExpect(MockMvcResultMatchers.model().errorCount(1))
+                .andExpect(
+                        MockMvcResultMatchers.model().attributeHasErrors(
+                                "space"))
+                .andExpect(
+                        MockMvcResultMatchers.model().attributeHasFieldErrors(
+                                "space", "binConfig"));
+
+        Assert.assertEquals("Must not have one more space", SPACE_NB,
+                this.spacesRepository.count());
+
+    }
+
+    @Test
+    public void testSpacePostUpdateAllErrors() throws Exception {
+
+        MockHttpServletRequestBuilder post = MockMvcRequestBuilders
+                .post("/admin/spaces/save");
+        post = post.param("id", this.spacesUuids.get(0));
+        post = post.param("title", "");
+        post = post.param("description", "New description");
+        post = post.param("uri", "http://ldt.iri.centrepompidou.fr/new/uri");
+        post = post.param("color", "#ffffff");
+        post = post.param("binConfig", "{");
+
+        this.mvc.perform(post)
+                .andExpect(MockMvcResultMatchers.status().isOk())
+                .andExpect(MockMvcResultMatchers.view().name("admin/spaceEdit"))
+                .andExpect(MockMvcResultMatchers.model().hasErrors())
+                .andExpect(MockMvcResultMatchers.model().errorCount(2))
+                .andExpect(
+                        MockMvcResultMatchers.model().attributeHasErrors(
+                                "space"))
+                .andExpect(
+                        MockMvcResultMatchers.model().attributeHasFieldErrors(
+                                "space", "title"))
+                .andExpect(
+                        MockMvcResultMatchers.model().attributeHasFieldErrors(
+                                "space", "binConfig"));
+
+        Space sp = this.spacesRepository.findOne(this.spacesUuids.get(0));
+
+        Assert.assertNotNull("Should find space", sp);
+        Assert.assertEquals("Bin config equals", "{}", sp.getBinConfig());
+        Assert.assertEquals("title equals", "test 0", sp.getTitle());
+
+    }
+
+    @Test
+    public void testSpacePostCreateAllErrors() throws Exception {
+
+        MockHttpServletRequestBuilder post = MockMvcRequestBuilders
+                .post("/admin/spaces/save");
+        post = post.param("title", "");
+        post = post.param("description", "New description");
+        post = post.param("uri", "http://ldt.iri.centrepompidou.fr/new/uri");
+        post = post.param("color", "#ffffff");
+        post = post.param("binConfig", "}");
+
+        this.mvc.perform(post)
+                .andExpect(MockMvcResultMatchers.status().isOk())
+                .andExpect(MockMvcResultMatchers.view().name("admin/spaceEdit"))
+                .andExpect(MockMvcResultMatchers.model().hasErrors())
+                .andExpect(MockMvcResultMatchers.model().errorCount(2))
+                .andExpect(
+                        MockMvcResultMatchers.model().attributeHasErrors(
+                                "space"))
+                .andExpect(
+                        MockMvcResultMatchers.model().attributeHasFieldErrors(
+                                "space", "title"))
+                .andExpect(
+                        MockMvcResultMatchers.model().attributeHasFieldErrors(
+                                "space", "binConfig"));
+
+        Assert.assertEquals("Must not have one more space", SPACE_NB,
+                this.spacesRepository.count());
+
+    }
+
+    @Test
+    public void testDeleteSpace() throws Exception {
+
+        MockHttpServletRequestBuilder get = MockMvcRequestBuilders
+                .get("/admin/spaces/delete/"
+                        + this.spacesUuids.get(SPACE_NB - 1));
+
+        MvcResult res = this.mvc
+                .perform(get)
+                .andExpect(MockMvcResultMatchers.status().isOk())
+                .andExpect(
+                        MockMvcResultMatchers.view().name(
+                                "admin/spaceDeleteConfirm"))
+                .andExpect(
+                        MockMvcResultMatchers.model().attributeExists(
+                                "spaceObj", "key", "salt")).andReturn();
+
+        Map<String, Object> model = res.getModelAndView().getModel();
+
+        Space space = (Space) model.get("spaceObj");
+        Assert.assertNotNull("Space is not null", space);
+        Assert.assertEquals("Must be first space id",
+                this.spacesUuids.get(SPACE_NB - 1), space.getId());
+
+        String key = (String) model.get("key");
+        Assert.assertNotNull("key is not null", key);
+
+        String salt = (String) model.get("salt");
+        Assert.assertNotNull("salt is not null", salt);
+
+        Assert.assertTrue("Key must be checked", space.checkKey(key, salt));
+
+    }
+
+    @Test
+    public void testDeleteFakeSpace() throws Exception {
+
+        MockHttpServletRequestBuilder get = MockMvcRequestBuilders
+                .get("/admin/spaces/delete/" + UUID.randomUUID().toString());
+
+        try {
+            this.mvc.perform(get).andExpect(
+                    MockMvcResultMatchers.status().isNotFound());
+        } catch (NestedServletException e) {
+            Assert.assertNotNull("Nested exception must not be null",
+                    e.getCause());
+            Assert.assertEquals(
+                    "Inner exception must be a HttpClientErrorException",
+                    HttpClientErrorException.class, e.getCause().getClass());
+            Assert.assertEquals("Exception error status must be not found",
+                    HttpStatus.NOT_FOUND,
+                    ((HttpClientErrorException) e.getCause()).getStatusCode());
+        }
+
+    }
+
+    @Test
+    public void testDeleteSpaceProject() throws Exception {
+
+        MockHttpServletRequestBuilder get = MockMvcRequestBuilders
+                .get("/admin/spaces/delete/" + this.spacesUuids.get(0));
+
+        try {
+            this.mvc.perform(get).andExpect(
+                    MockMvcResultMatchers.status().isBadRequest());
+        } catch (NestedServletException e) {
+            Assert.assertNotNull("Nested exception must not be null",
+                    e.getCause());
+            Assert.assertEquals(
+                    "Inner exception must be a HttpClientErrorException",
+                    HttpClientErrorException.class, e.getCause().getClass());
+            Assert.assertEquals("Exception error status must be not found",
+                    HttpStatus.BAD_REQUEST,
+                    ((HttpClientErrorException) e.getCause()).getStatusCode());
+        }
+
+    }
+
+    @Test
+    public void testDoDeleteSpaceNoKey() throws Exception {
+        MockHttpServletRequestBuilder post = MockMvcRequestBuilders
+                .post("/admin/spaces/delete/"
+                        + this.spacesUuids.get(SPACE_NB - 1));
+
+        try {
+            this.mvc.perform(post).andExpect(
+                    MockMvcResultMatchers.status().isBadRequest());
+        } catch (NestedServletException e) {
+            Assert.assertNotNull("Nested exception must not be null",
+                    e.getCause());
+            Assert.assertEquals(
+                    "Inner exception must be a HttpClientErrorException",
+                    HttpClientErrorException.class, e.getCause().getClass());
+            Assert.assertEquals("Exception error status must be not found",
+                    HttpStatus.BAD_REQUEST,
+                    ((HttpClientErrorException) e.getCause()).getStatusCode());
+        }
+
+        Assert.assertEquals("Must have same nb of space", SPACE_NB,
+                this.spacesRepository.count());
+
+    }
+
+    @Test
+    public void testDoDeleteSpace() throws Exception {
+
+        Space space = this.spacesList.get(this.spacesUuids.get(SPACE_NB - 1));
+
+        SecureRandom rand = SecureRandom.getInstance("SHA1PRNG");
+        rand.setSeed(System.currentTimeMillis());
+        byte[] rawSalt = new byte[50];
+        rand.nextBytes(rawSalt);
+        String salt = Hex.encodeHexString(rawSalt);
+        String key = space.getKey(salt);
+
+        MockHttpServletRequestBuilder post = MockMvcRequestBuilders.post(String
+                .format("/admin/spaces/delete/%s?key=%s&salt=%s",
+                        this.spacesUuids.get(SPACE_NB - 1), key, salt));
+
+        this.mvc.perform(post)
+                .andExpect(MockMvcResultMatchers.status().isSeeOther())
+                .andExpect(MockMvcResultMatchers.redirectedUrl("/admin/spaces"));
+
+        Assert.assertEquals("Must have one less space", SPACE_NB - 1,
+                this.spacesRepository.count());
+
+        space = this.spacesRepository.findOne(this.spacesUuids
+                .get(SPACE_NB - 1));
+
+        Assert.assertNull("Space " + this.spacesUuids.get(SPACE_NB - 1)
+                + " deleted", space);
+
+    }
+
+    @Test
+    public void testDoDeleteSpaceFake() throws Exception {
+
+        Space space = this.spacesList.get(this.spacesUuids.get(SPACE_NB - 1));
+
+        SecureRandom rand = SecureRandom.getInstance("SHA1PRNG");
+        rand.setSeed(System.currentTimeMillis());
+        byte[] rawSalt = new byte[50];
+        rand.nextBytes(rawSalt);
+        String salt = Hex.encodeHexString(rawSalt);
+        String key = space.getKey(salt);
+
+        MockHttpServletRequestBuilder post = MockMvcRequestBuilders.post(String
+                .format("/admin/spaces/delete/%s?key=%s&salt=%s",
+                        UUID.randomUUID(), key, salt));
+
+        this.mvc.perform(post)
+                .andExpect(MockMvcResultMatchers.status().isSeeOther())
+                .andExpect(MockMvcResultMatchers.redirectedUrl("/admin/spaces"));
+
+        Assert.assertEquals("Must have the same nb of space", SPACE_NB,
+                this.spacesRepository.count());
+
+    }
+
+    @Test
+    public void testDoDeleteSpaceProject() throws Exception {
+
+        Space space = this.spacesList.get(this.spacesUuids.get(0));
+
+        SecureRandom rand = SecureRandom.getInstance("SHA1PRNG");
+        rand.setSeed(System.currentTimeMillis());
+        byte[] rawSalt = new byte[50];
+        rand.nextBytes(rawSalt);
+        String salt = Hex.encodeHexString(rawSalt);
+        String key = space.getKey(salt);
+
+        MockHttpServletRequestBuilder post = MockMvcRequestBuilders.post(String
+                .format("/admin/spaces/delete/%s?key=%s&salt=%s",
+                        this.spacesUuids.get(0), key, salt));
+
+        try {
+            this.mvc.perform(post).andExpect(
+                    MockMvcResultMatchers.status().isBadRequest());
+        } catch (NestedServletException e) {
+            Assert.assertNotNull("Nested exception must not be null",
+                    e.getCause());
+            Assert.assertEquals(
+                    "Inner exception must be a HttpClientErrorException",
+                    HttpClientErrorException.class, e.getCause().getClass());
+            Assert.assertEquals("Exception error status must be not found",
+                    HttpStatus.BAD_REQUEST,
+                    ((HttpClientErrorException) e.getCause()).getStatusCode());
+        }
+
+        Assert.assertEquals("Must have the same nb of space", SPACE_NB,
+                this.spacesRepository.count());
+
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/server/src/test/java/org/iri_research/renkan/test/controller/UsersAdminControllerTest.java	Fri Nov 15 09:34:41 2013 +0100
@@ -0,0 +1,584 @@
+package org.iri_research.renkan.test.controller;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+import java.util.UUID;
+
+import org.iri_research.renkan.models.Project;
+import org.iri_research.renkan.models.Space;
+import org.iri_research.renkan.models.User;
+import org.iri_research.renkan.repositories.ProjectsRepository;
+import org.iri_research.renkan.repositories.SpacesRepository;
+import org.iri_research.renkan.repositories.UsersRepository;
+import org.joda.time.DateTime;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
+import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
+import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+import org.springframework.web.context.WebApplicationContext;
+
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@WebAppConfiguration
+@ContextConfiguration(locations = { "controller-context.xml",
+        "file:src/main/webapp/WEB-INF/spring-servlet.xml" })
+public class UsersAdminControllerTest {
+
+    private final static int SPACE_NB = 3;
+    private final static int USER_NB = 3;
+
+    private Logger logger = LoggerFactory.getLogger(UsersAdminControllerTest.class);
+
+    @Autowired
+    private SpacesRepository spacesRepository;
+    @Autowired
+    private ProjectsRepository projectsRepository;
+    @Autowired
+    private UsersRepository usersRepository;
+    
+    @Autowired
+    private PasswordEncoder renkanPasswordEncoder;
+
+    private Map<String, Space> spacesList = new HashMap<String, Space>(SPACE_NB);
+    private List<String> spacesUuids = new ArrayList<>(SPACE_NB);
+
+    private ArrayList<Project> testProjects = new ArrayList<Project>();
+    
+    private Map<String, User> usersList = new HashMap<String, User>(USER_NB);
+    private List<String> usersUuids = new ArrayList<>(USER_NB);
+    
+
+    @Autowired
+    private WebApplicationContext context;
+    private MockMvc mvc;
+
+    @Before
+    public void setup() {
+
+        logger.debug("Setup");
+        TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+        spacesRepository.deleteAll();
+        projectsRepository.deleteAll();
+        usersRepository.deleteAll();
+
+        for(int i=0; i < USER_NB; i++) {
+            String uuid = UUID.randomUUID().toString();
+            User user = new User(uuid, "user" + i, "User nb 1", "http://www.iri.centrepompidou.fr", "#ababab");
+            user.setLocked(false);
+            user.setEnabled(true);
+            user.setAvatar("A pretty picture");
+            user.setExpirationDate(new DateTime());
+            user.setCredentialExpirationDate(new DateTime());
+            user.setEmail(String.format("user%d@mail.com", i));
+            user = usersRepository.save(user);
+            this.usersUuids.add(uuid);
+            this.usersList.put(uuid, user);
+        }
+        
+        ArrayList<Project> pl = new ArrayList<Project>();
+        for (int i = 0; i < SPACE_NB; i++) {
+            DateTime creationDate = new DateTime();
+            String uuid = UUID.randomUUID().toString();
+            spacesUuids.add(uuid);
+            Space testSpace = new Space(uuid, "test " + i, "Test space " + 1,
+                    "{}", "http://ldt.iri.centrepompidou.fr", "#ababab",
+                    "test_user", "http://ldt.iri.centrepompidou.fr",
+                    creationDate);
+            testSpace = spacesRepository.save(testSpace);
+            this.spacesList.put(uuid, testSpace);
+            for (int j = 0; j < SPACE_NB - 1 - i; j++) {
+                Project p = new Project(testSpace.getId(), UUID.randomUUID()
+                        .toString(), "test" + ((SPACE_NB - 1) * i + j + 1),
+                        "desc" + ((SPACE_NB - 1) * i + j + 1),
+                        "http://localhost:8080/rest/projects/id"
+                                + ((SPACE_NB - 1) * i + j + 1), creationDate);
+                p.addUser(this.usersList.get(this.usersUuids.get(0)));
+                pl.add(p);
+            }
+            try {
+                Thread.sleep(1);
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+        }
+
+        for (Project p : projectsRepository.save(pl)) {
+            this.testProjects.add(p);
+        }
+        
+        
+
+        this.mvc = MockMvcBuilders.webAppContextSetup(this.context).build();
+    }
+
+    @After
+    public void teardown() {
+        spacesRepository.deleteAll();
+        projectsRepository.deleteAll();
+    }
+
+    @Test
+    public void testUserPostUpdate() throws Exception {
+
+        MockHttpServletRequestBuilder post = MockMvcRequestBuilders
+                .post("/admin/users/save");
+        post = post.param("id", this.usersUuids.get(0));
+        post = post.param("title", "New name");
+        post = post.param("description", "New description");
+        post = post.param("uri", "http://ldt.iri.centrepompidou.fr/new/uri");
+        post = post.param("color", "#ffffff");
+
+        this.mvc.perform(post)
+                .andExpect(MockMvcResultMatchers.status().isSeeOther())
+                .andExpect(MockMvcResultMatchers.redirectedUrl("/admin/users"));
+
+        User user = this.usersRepository.findOne(this.usersUuids.get(0));
+
+        Assert.assertNotNull("Should find space", user);
+        Assert.assertEquals("Title equals", "New name", user.getTitle());
+        Assert.assertEquals("Description equals", "New description",
+                user.getDescription());
+        Assert.assertEquals("Uri equals",
+                "http://ldt.iri.centrepompidou.fr/new/uri", user.getUri());
+        Assert.assertEquals("Color equals", "#ffffff", user.getColor());
+    }
+
+    @Test
+    public void testUserPostCreate() throws Exception {
+
+        MockHttpServletRequestBuilder post = MockMvcRequestBuilders
+                .post("/admin/users/save")
+                    .param("title", "New name")
+                    .param("description", "New description")
+                    .param("uri", "http://ldt.iri.centrepompidou.fr/new/uri")
+                    .param("color", "#ffffff")
+                    .param("expirationDate","2007-11-24")
+                    .param("credentialExpirationDate","2009-11-29")
+                    .param("password", "test")
+                    .param("passwordConfirm", "test");
+
+        this.mvc.perform(post)
+                .andExpect(MockMvcResultMatchers.status().isSeeOther())
+                .andExpect(MockMvcResultMatchers.redirectedUrl("/admin/users"));
+
+        Assert.assertEquals("Must have one more space", USER_NB + 1,
+                this.usersRepository.count());
+
+        for (User user : this.usersRepository.findAll()) {
+            if (this.usersList.containsKey(user.getId())) {
+                continue;
+            }
+            else {
+                Assert.assertNotNull("Should find space", user);
+                Assert.assertEquals("Title equals", "New name", user.getTitle());
+                Assert.assertEquals("Description equals", "New description",
+                        user.getDescription());
+                Assert.assertEquals("Uri equals",
+                        "http://ldt.iri.centrepompidou.fr/new/uri", user.getUri());
+                Assert.assertEquals("Color equals", "#ffffff", user.getColor());
+                Assert.assertTrue(
+                        "id sould match uuid regex",
+                        user.getId()
+                                .matches(
+                                        "[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}"));
+                Assert.assertTrue("password must match \"test\"", renkanPasswordEncoder.matches("test", user.getPassword()));
+                Assert.assertEquals(new DateTime(2007, 11, 24, 0, 0, 0, 0), user.getExpirationDate());
+            }
+        }
+    }
+//
+//    @Test
+//    public void testSpacePostUpdateEmptyTitle() throws Exception {
+//
+//        MockHttpServletRequestBuilder post = MockMvcRequestBuilders
+//                .post("/admin/spaces/save");
+//        post = post.param("id", this.spacesUuids.get(0));
+//        post = post.param("title", "");
+//        post = post.param("description", "New description");
+//        post = post.param("uri", "http://ldt.iri.centrepompidou.fr/new/uri");
+//        post = post.param("color", "#ffffff");
+//        post = post.param("binConfig", "{}");
+//
+//        this.mvc.perform(post)
+//                .andExpect(MockMvcResultMatchers.status().isOk())
+//                .andExpect(MockMvcResultMatchers.view().name("admin/spaceEdit"))
+//                .andExpect(MockMvcResultMatchers.model().hasErrors())
+//                .andExpect(MockMvcResultMatchers.model().errorCount(1))
+//                .andExpect(
+//                        MockMvcResultMatchers.model().attributeHasErrors(
+//                                "space"))
+//                .andExpect(
+//                        MockMvcResultMatchers.model().attributeHasFieldErrors(
+//                                "space", "title"));
+//
+//        Space sp = this.spacesRepository.findOne(this.spacesUuids.get(0));
+//
+//        Assert.assertNotNull("Should find space", sp);
+//        Assert.assertEquals("Title equals", "test 0", sp.getTitle());
+//
+//    }
+//
+//    @Test
+//    public void testSpacePostCreateEmptyTitle() throws Exception {
+//
+//        MockHttpServletRequestBuilder post = MockMvcRequestBuilders
+//                .post("/admin/spaces/save");
+//        post = post.param("title", "");
+//        post = post.param("description", "New description");
+//        post = post.param("uri", "http://ldt.iri.centrepompidou.fr/new/uri");
+//        post = post.param("color", "#ffffff");
+//        post = post.param("binConfig", "{}");
+//
+//        this.mvc.perform(post)
+//                .andExpect(MockMvcResultMatchers.status().isOk())
+//                .andExpect(MockMvcResultMatchers.view().name("admin/spaceEdit"))
+//                .andExpect(MockMvcResultMatchers.model().hasErrors())
+//                .andExpect(MockMvcResultMatchers.model().errorCount(1))
+//                .andExpect(
+//                        MockMvcResultMatchers.model().attributeHasErrors(
+//                                "space"))
+//                .andExpect(
+//                        MockMvcResultMatchers.model().attributeHasFieldErrors(
+//                                "space", "title"));
+//
+//        Assert.assertEquals("Must not have one more space", SPACE_NB,
+//                this.spacesRepository.count());
+//
+//    }
+//
+//    @Test
+//    public void testSpacePostUpdateBadJson() throws Exception {
+//
+//        MockHttpServletRequestBuilder post = MockMvcRequestBuilders
+//                .post("/admin/spaces/save");
+//        post = post.param("id", this.spacesUuids.get(0));
+//        post = post.param("title", "New Title");
+//        post = post.param("description", "New description");
+//        post = post.param("uri", "http://ldt.iri.centrepompidou.fr/new/uri");
+//        post = post.param("color", "#ffffff");
+//        post = post.param("binConfig", "{");
+//
+//        this.mvc.perform(post)
+//                .andExpect(MockMvcResultMatchers.status().isOk())
+//                .andExpect(MockMvcResultMatchers.view().name("admin/spaceEdit"))
+//                .andExpect(MockMvcResultMatchers.model().hasErrors())
+//                .andExpect(MockMvcResultMatchers.model().errorCount(1))
+//                .andExpect(
+//                        MockMvcResultMatchers.model().attributeHasErrors(
+//                                "space"))
+//                .andExpect(
+//                        MockMvcResultMatchers.model().attributeHasFieldErrors(
+//                                "space", "binConfig"));
+//
+//        Space sp = this.spacesRepository.findOne(this.spacesUuids.get(0));
+//
+//        Assert.assertNotNull("Should find space", sp);
+//        Assert.assertEquals("Bin config equals", "{}", sp.getBinConfig());
+//
+//    }
+//
+//    @Test
+//    public void testSpacePostCreateBadJson() throws Exception {
+//
+//        MockHttpServletRequestBuilder post = MockMvcRequestBuilders
+//                .post("/admin/spaces/save");
+//        post = post.param("title", "New Title");
+//        post = post.param("description", "New description");
+//        post = post.param("uri", "http://ldt.iri.centrepompidou.fr/new/uri");
+//        post = post.param("color", "#ffffff");
+//        post = post.param("binConfig", "}");
+//
+//        this.mvc.perform(post)
+//                .andExpect(MockMvcResultMatchers.status().isOk())
+//                .andExpect(MockMvcResultMatchers.view().name("admin/spaceEdit"))
+//                .andExpect(MockMvcResultMatchers.model().hasErrors())
+//                .andExpect(MockMvcResultMatchers.model().errorCount(1))
+//                .andExpect(
+//                        MockMvcResultMatchers.model().attributeHasErrors(
+//                                "space"))
+//                .andExpect(
+//                        MockMvcResultMatchers.model().attributeHasFieldErrors(
+//                                "space", "binConfig"));
+//
+//        Assert.assertEquals("Must not have one more space", SPACE_NB,
+//                this.spacesRepository.count());
+//
+//    }
+//
+//    @Test
+//    public void testSpacePostUpdateAllErrors() throws Exception {
+//
+//        MockHttpServletRequestBuilder post = MockMvcRequestBuilders
+//                .post("/admin/spaces/save");
+//        post = post.param("id", this.spacesUuids.get(0));
+//        post = post.param("title", "");
+//        post = post.param("description", "New description");
+//        post = post.param("uri", "http://ldt.iri.centrepompidou.fr/new/uri");
+//        post = post.param("color", "#ffffff");
+//        post = post.param("binConfig", "{");
+//
+//        this.mvc.perform(post)
+//                .andExpect(MockMvcResultMatchers.status().isOk())
+//                .andExpect(MockMvcResultMatchers.view().name("admin/spaceEdit"))
+//                .andExpect(MockMvcResultMatchers.model().hasErrors())
+//                .andExpect(MockMvcResultMatchers.model().errorCount(2))
+//                .andExpect(
+//                        MockMvcResultMatchers.model().attributeHasErrors(
+//                                "space"))
+//                .andExpect(
+//                        MockMvcResultMatchers.model().attributeHasFieldErrors(
+//                                "space", "title"))
+//                .andExpect(
+//                        MockMvcResultMatchers.model().attributeHasFieldErrors(
+//                                "space", "binConfig"));
+//
+//        Space sp = this.spacesRepository.findOne(this.spacesUuids.get(0));
+//
+//        Assert.assertNotNull("Should find space", sp);
+//        Assert.assertEquals("Bin config equals", "{}", sp.getBinConfig());
+//        Assert.assertEquals("title equals", "test 0", sp.getTitle());
+//
+//    }
+//
+//    @Test
+//    public void testSpacePostCreateAllErrors() throws Exception {
+//
+//        MockHttpServletRequestBuilder post = MockMvcRequestBuilders
+//                .post("/admin/spaces/save");
+//        post = post.param("title", "");
+//        post = post.param("description", "New description");
+//        post = post.param("uri", "http://ldt.iri.centrepompidou.fr/new/uri");
+//        post = post.param("color", "#ffffff");
+//        post = post.param("binConfig", "}");
+//
+//        this.mvc.perform(post)
+//                .andExpect(MockMvcResultMatchers.status().isOk())
+//                .andExpect(MockMvcResultMatchers.view().name("admin/spaceEdit"))
+//                .andExpect(MockMvcResultMatchers.model().hasErrors())
+//                .andExpect(MockMvcResultMatchers.model().errorCount(2))
+//                .andExpect(
+//                        MockMvcResultMatchers.model().attributeHasErrors(
+//                                "space"))
+//                .andExpect(
+//                        MockMvcResultMatchers.model().attributeHasFieldErrors(
+//                                "space", "title"))
+//                .andExpect(
+//                        MockMvcResultMatchers.model().attributeHasFieldErrors(
+//                                "space", "binConfig"));
+//
+//        Assert.assertEquals("Must not have one more space", SPACE_NB,
+//                this.spacesRepository.count());
+//
+//    }
+//
+//    @Test
+//    public void testDeleteSpace() throws Exception {
+//
+//        MockHttpServletRequestBuilder get = MockMvcRequestBuilders
+//                .get("/admin/spaces/delete/"
+//                        + this.spacesUuids.get(SPACE_NB - 1));
+//
+//        MvcResult res = this.mvc
+//                .perform(get)
+//                .andExpect(MockMvcResultMatchers.status().isOk())
+//                .andExpect(
+//                        MockMvcResultMatchers.view().name(
+//                                "admin/spaceDeleteConfirm"))
+//                .andExpect(
+//                        MockMvcResultMatchers.model().attributeExists(
+//                                "spaceObj", "key", "salt")).andReturn();
+//
+//        Map<String, Object> model = res.getModelAndView().getModel();
+//
+//        Space space = (Space) model.get("spaceObj");
+//        Assert.assertNotNull("Space is not null", space);
+//        Assert.assertEquals("Must be first space id",
+//                this.spacesUuids.get(SPACE_NB - 1), space.getId());
+//
+//        String key = (String) model.get("key");
+//        Assert.assertNotNull("key is not null", key);
+//
+//        String salt = (String) model.get("salt");
+//        Assert.assertNotNull("salt is not null", salt);
+//
+//        Assert.assertTrue("Key must be checked", space.checkKey(key, salt));
+//
+//    }
+//
+//    @Test
+//    public void testDeleteFakeSpace() throws Exception {
+//
+//        MockHttpServletRequestBuilder get = MockMvcRequestBuilders
+//                .get("/admin/spaces/delete/" + UUID.randomUUID().toString());
+//
+//        try {
+//            this.mvc.perform(get).andExpect(
+//                    MockMvcResultMatchers.status().isNotFound());
+//        } catch (NestedServletException e) {
+//            Assert.assertNotNull("Nested exception must not be null",
+//                    e.getCause());
+//            Assert.assertEquals(
+//                    "Inner exception must be a HttpClientErrorException",
+//                    HttpClientErrorException.class, e.getCause().getClass());
+//            Assert.assertEquals("Exception error status must be not found",
+//                    HttpStatus.NOT_FOUND,
+//                    ((HttpClientErrorException) e.getCause()).getStatusCode());
+//        }
+//
+//    }
+//
+//    @Test
+//    public void testDeleteSpaceProject() throws Exception {
+//
+//        MockHttpServletRequestBuilder get = MockMvcRequestBuilders
+//                .get("/admin/spaces/delete/" + this.spacesUuids.get(0));
+//
+//        try {
+//            this.mvc.perform(get).andExpect(
+//                    MockMvcResultMatchers.status().isBadRequest());
+//        } catch (NestedServletException e) {
+//            Assert.assertNotNull("Nested exception must not be null",
+//                    e.getCause());
+//            Assert.assertEquals(
+//                    "Inner exception must be a HttpClientErrorException",
+//                    HttpClientErrorException.class, e.getCause().getClass());
+//            Assert.assertEquals("Exception error status must be not found",
+//                    HttpStatus.BAD_REQUEST,
+//                    ((HttpClientErrorException) e.getCause()).getStatusCode());
+//        }
+//
+//    }
+//
+//    @Test
+//    public void testDoDeleteSpaceNoKey() throws Exception {
+//        MockHttpServletRequestBuilder post = MockMvcRequestBuilders
+//                .post("/admin/spaces/delete/"
+//                        + this.spacesUuids.get(SPACE_NB - 1));
+//
+//        try {
+//            this.mvc.perform(post).andExpect(
+//                    MockMvcResultMatchers.status().isBadRequest());
+//        } catch (NestedServletException e) {
+//            Assert.assertNotNull("Nested exception must not be null",
+//                    e.getCause());
+//            Assert.assertEquals(
+//                    "Inner exception must be a HttpClientErrorException",
+//                    HttpClientErrorException.class, e.getCause().getClass());
+//            Assert.assertEquals("Exception error status must be not found",
+//                    HttpStatus.BAD_REQUEST,
+//                    ((HttpClientErrorException) e.getCause()).getStatusCode());
+//        }
+//
+//        Assert.assertEquals("Must have same nb of space", SPACE_NB,
+//                this.spacesRepository.count());
+//
+//    }
+//
+//    @Test
+//    public void testDoDeleteSpace() throws Exception {
+//
+//        Space space = this.spacesList.get(this.spacesUuids.get(SPACE_NB - 1));
+//
+//        SecureRandom rand = SecureRandom.getInstance("SHA1PRNG");
+//        rand.setSeed(System.currentTimeMillis());
+//        byte[] rawSalt = new byte[50];
+//        rand.nextBytes(rawSalt);
+//        String salt = Hex.encodeHexString(rawSalt);
+//        String key = space.getKey(salt);
+//
+//        MockHttpServletRequestBuilder post = MockMvcRequestBuilders.post(String
+//                .format("/admin/spaces/delete/%s?key=%s&salt=%s",
+//                        this.spacesUuids.get(SPACE_NB - 1), key, salt));
+//
+//        this.mvc.perform(post)
+//                .andExpect(MockMvcResultMatchers.status().isSeeOther())
+//                .andExpect(MockMvcResultMatchers.redirectedUrl("/admin/spaces"));
+//
+//        Assert.assertEquals("Must have one less space", SPACE_NB - 1,
+//                this.spacesRepository.count());
+//
+//        space = this.spacesRepository.findOne(this.spacesUuids
+//                .get(SPACE_NB - 1));
+//
+//        Assert.assertNull("Space " + this.spacesUuids.get(SPACE_NB - 1)
+//                + " deleted", space);
+//
+//    }
+//
+//    @Test
+//    public void testDoDeleteSpaceFake() throws Exception {
+//
+//        Space space = this.spacesList.get(this.spacesUuids.get(SPACE_NB - 1));
+//
+//        SecureRandom rand = SecureRandom.getInstance("SHA1PRNG");
+//        rand.setSeed(System.currentTimeMillis());
+//        byte[] rawSalt = new byte[50];
+//        rand.nextBytes(rawSalt);
+//        String salt = Hex.encodeHexString(rawSalt);
+//        String key = space.getKey(salt);
+//
+//        MockHttpServletRequestBuilder post = MockMvcRequestBuilders.post(String
+//                .format("/admin/spaces/delete/%s?key=%s&salt=%s",
+//                        UUID.randomUUID(), key, salt));
+//
+//        this.mvc.perform(post)
+//                .andExpect(MockMvcResultMatchers.status().isSeeOther())
+//                .andExpect(MockMvcResultMatchers.redirectedUrl("/admin/spaces"));
+//
+//        Assert.assertEquals("Must have the same nb of space", SPACE_NB,
+//                this.spacesRepository.count());
+//
+//    }
+//
+//    @Test
+//    public void testDoDeleteSpaceProject() throws Exception {
+//
+//        Space space = this.spacesList.get(this.spacesUuids.get(0));
+//
+//        SecureRandom rand = SecureRandom.getInstance("SHA1PRNG");
+//        rand.setSeed(System.currentTimeMillis());
+//        byte[] rawSalt = new byte[50];
+//        rand.nextBytes(rawSalt);
+//        String salt = Hex.encodeHexString(rawSalt);
+//        String key = space.getKey(salt);
+//
+//        MockHttpServletRequestBuilder post = MockMvcRequestBuilders.post(String
+//                .format("/admin/spaces/delete/%s?key=%s&salt=%s",
+//                        this.spacesUuids.get(0), key, salt));
+//
+//        try {
+//            this.mvc.perform(post).andExpect(
+//                    MockMvcResultMatchers.status().isBadRequest());
+//        } catch (NestedServletException e) {
+//            Assert.assertNotNull("Nested exception must not be null",
+//                    e.getCause());
+//            Assert.assertEquals(
+//                    "Inner exception must be a HttpClientErrorException",
+//                    HttpClientErrorException.class, e.getCause().getClass());
+//            Assert.assertEquals("Exception error status must be not found",
+//                    HttpStatus.BAD_REQUEST,
+//                    ((HttpClientErrorException) e.getCause()).getStatusCode());
+//        }
+//
+//        Assert.assertEquals("Must have the same nb of space", SPACE_NB,
+//                this.spacesRepository.count());
+//
+//    }
+
+}
--- a/server/src/test/java/org/iri_research/renkan/test/repositories/ProjectSyncsRepositoryTest.java	Thu Nov 07 10:42:18 2013 +0100
+++ b/server/src/test/java/org/iri_research/renkan/test/repositories/ProjectSyncsRepositoryTest.java	Fri Nov 15 09:34:41 2013 +0100
@@ -1,7 +1,7 @@
 package org.iri_research.renkan.test.repositories;
 
 import java.util.ArrayList;
-import java.util.Date;
+import java.util.TimeZone;
 import java.util.UUID;
 
 import org.iri_research.renkan.RenkanException;
@@ -11,6 +11,7 @@
 import org.iri_research.renkan.repositories.ProjectSyncsRepository;
 import org.iri_research.renkan.repositories.ProjectsRepository;
 import org.iri_research.renkan.repositories.SpacesRepository;
+import org.joda.time.DateTime;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -47,14 +48,15 @@
     public void setup() {
 
         logger.debug("Setup");
+        TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
         Space testSpace = new Space(UUID.randomUUID().toString(), "test",
                 "Test space", null, null, null, "test_user", null, null);
         testSpace = spacesRepository.save(testSpace);
         ArrayList<Project> pl = new ArrayList<Project>();
         pl.add(new Project(testSpace.getId(), null, "test1", "desc1",
-                "http://localhost:8080/rest/projects/id1", new Date()));
+                "http://localhost:8080/rest/projects/id1", new DateTime()));
         pl.add(new Project(testSpace.getId(), null, "test2", "desc2",
-                "http://localhost:8080/rest/projects/id2", new Date()));
+                "http://localhost:8080/rest/projects/id2", new DateTime()));
         logger.debug("Setup : new Project ");
         for (Project p : projectRepository.save(pl)) {
             this.testProjects.add(p);
--- a/server/src/test/java/org/iri_research/renkan/test/repositories/ProjectsRepositoryTest.java	Thu Nov 07 10:42:18 2013 +0100
+++ b/server/src/test/java/org/iri_research/renkan/test/repositories/ProjectsRepositoryTest.java	Fri Nov 15 09:34:41 2013 +0100
@@ -2,9 +2,9 @@
 
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Date;
 import java.util.List;
 import java.util.Map;
+import java.util.TimeZone;
 import java.util.UUID;
 
 import org.iri_research.renkan.models.Edge;
@@ -20,6 +20,7 @@
 import org.iri_research.renkan.repositories.SpacesRepository;
 import org.iri_research.renkan.repositories.UsersRepository;
 import org.iri_research.renkan.utils.ColorGenerator;
+import org.joda.time.DateTime;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -76,7 +77,7 @@
     private List<Edge> testEdges = new ArrayList<>();
     private List<User> testUsers = new ArrayList<>();
 
-    private Date creationDate = new Date();
+    private DateTime creationDate = new DateTime();
 
     private List<String> spaceIds = new ArrayList<>();
 
@@ -88,6 +89,7 @@
     @Before
     public void setup() {
 
+        TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
         logger.debug("Setup");
 
         // CREATE USERS
--- a/server/src/test/java/org/iri_research/renkan/test/repositories/SpacesRepositoryTest.java	Thu Nov 07 10:42:18 2013 +0100
+++ b/server/src/test/java/org/iri_research/renkan/test/repositories/SpacesRepositoryTest.java	Fri Nov 15 09:34:41 2013 +0100
@@ -1,14 +1,15 @@
 package org.iri_research.renkan.test.repositories;
 
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.TimeZone;
 import java.util.UUID;
 
 import org.iri_research.renkan.models.Space;
 import org.iri_research.renkan.repositories.SpacesRepository;
+import org.joda.time.DateTime;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -50,9 +51,10 @@
     public void setup() {
 
         logger.debug("Setup");
+        TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
         spacesRepository.deleteAll();
         for (int i = 0; i < SPACE_NB; i++) {
-            Date creationDate = new Date();
+            DateTime creationDate = new DateTime();
             String uuid = UUID.randomUUID().toString();
             spacesUuids.add(uuid);
             Space testSpace = new Space(uuid, "test " + i, "Test space " + 1,
@@ -111,7 +113,7 @@
 
             Assert.assertTrue("mongo object must have created field",
                     obj.containsField("created"));
-            Assert.assertEquals("Created must be the same", obj.get("created"),
+            Assert.assertEquals("Created must be the same", new DateTime(obj.get("created")),
                     sp.getCreated());
 
             Assert.assertTrue("mongo object must have bin_config field",
--- a/server/src/test/java/org/iri_research/renkan/test/rest/ProjectRestTest.java	Thu Nov 07 10:42:18 2013 +0100
+++ b/server/src/test/java/org/iri_research/renkan/test/rest/ProjectRestTest.java	Fri Nov 15 09:34:41 2013 +0100
@@ -1,16 +1,16 @@
 package org.iri_research.renkan.test.rest;
 
+import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.List;
+import java.util.TimeZone;
 import java.util.UUID;
 
 import javax.ws.rs.client.WebTarget;
 import javax.ws.rs.core.Application;
+import javax.ws.rs.core.MediaType;
 
 import org.glassfish.jersey.server.ResourceConfig;
-import org.glassfish.jersey.server.spring.SpringLifecycleListener;
-import org.glassfish.jersey.server.spring.scope.RequestContextFilter;
 import org.glassfish.jersey.test.JerseyTest;
 import org.iri_research.renkan.models.Edge;
 import org.iri_research.renkan.models.Node;
@@ -21,6 +21,9 @@
 import org.iri_research.renkan.repositories.ProjectRevisionsRepository;
 import org.iri_research.renkan.repositories.ProjectsRepository;
 import org.iri_research.renkan.repositories.SpacesRepository;
+import org.iri_research.renkan.rest.RestApplication;
+import org.joda.time.DateTime;
+import org.joda.time.format.ISODateTimeFormat;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -34,6 +37,10 @@
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.datatype.joda.JodaModule;
 import com.mongodb.BasicDBObject;
 import com.mongodb.DBCollection;
 import com.mongodb.DBCursor;
@@ -69,9 +76,16 @@
     private List<Node> testNodes = new ArrayList<Node>();
     private List<Edge> testEdges = new ArrayList<>();
 
-    private Date creationDate = new Date();
+    private DateTime creationDate = new DateTime();
 
     private String spaceId = UUID.randomUUID().toString();
+    private String projectId = UUID.randomUUID().toString();
+    
+    private ObjectMapper getObjectMapper() {
+        ObjectMapper mapper = new ObjectMapper();
+        mapper.registerModule(new JodaModule());
+        return mapper;
+    }
 
     public ProjectRestTest() {
     }
@@ -91,10 +105,8 @@
 
     @Override
     protected Application configure() {
-        ResourceConfig rc = new ResourceConfig()
-                .packages("org.iri_research.renkan.rest")
-                .register(SpringLifecycleListener.class)
-                .register(RequestContextFilter.class)
+        TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+        ResourceConfig rc = new RestApplication()
                 .property("contextConfigLocation",
                         "classpath:/org/iri_research/renkan/test/rest/rest-context.xml");
         rc.setApplicationName("rest");
@@ -108,8 +120,7 @@
         Space testSpace = new Space(this.spaceId, "test space", "Test space",
                 null, null, null, "test_user", null, this.creationDate);
         testSpace = spacesRepository.save(testSpace);
-        testProject = new Project(testSpace.getId(), UUID.randomUUID()
-                .toString(), "test", "desc",
+        testProject = new Project(testSpace.getId(), this.projectId, "test", "desc",
                 "http://localhost:8080/rest/projects/id", this.creationDate);
 
         for (int i = 0; i < 3; i++) {
@@ -145,6 +156,28 @@
         projectsRepository.deleteAll();
         spacesRepository.deleteAll();
     }
+    
+    @Test
+    public void testGetProject() throws JsonProcessingException, IOException {
+        WebTarget webResource = this.target();
+        String respString = webResource.path("projects")
+                .path(testProject.getId()).request().acceptEncoding("UTF-8").accept(MediaType.APPLICATION_JSON_TYPE).get(String.class);
+        Assert.assertNotNull("get resp String not empty", respString);
+        Assert.assertFalse("get resp String non empty", respString.isEmpty());
+        
+        logger.debug("Test get Project : respString : " + respString);
+        
+        ObjectMapper mapper = this.getObjectMapper();
+        
+        JsonNode projectNode = mapper.readTree(respString);
+        
+        Assert.assertNotNull("project node not null", projectNode);
+        
+        Assert.assertNotNull("Must have an id", projectNode.get("id"));
+        Assert.assertEquals("id must match", this.projectId, projectNode.get("id").asText());
+        Assert.assertNotNull("Must have a created date", projectNode.get("created"));
+        Assert.assertEquals("creation date must match", this.creationDate.toString(ISODateTimeFormat.dateTime()), projectNode.get("created").asText());
+    }
 
     @Test
     public void testDeleteProject() {
--- a/server/src/test/java/org/iri_research/renkan/test/rest/SpaceRestTest.java	Thu Nov 07 10:42:18 2013 +0100
+++ b/server/src/test/java/org/iri_research/renkan/test/rest/SpaceRestTest.java	Fri Nov 15 09:34:41 2013 +0100
@@ -2,9 +2,9 @@
 
 import java.io.IOException;
 import java.net.URI;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.TimeZone;
 import java.util.UUID;
 
 import javax.ws.rs.client.Entity;
@@ -16,11 +16,10 @@
 
 import org.glassfish.jersey.server.ResourceConfig;
 import org.glassfish.jersey.server.model.Resource;
-import org.glassfish.jersey.server.spring.SpringLifecycleListener;
-import org.glassfish.jersey.server.spring.scope.RequestContextFilter;
 import org.glassfish.jersey.test.JerseyTest;
 import org.iri_research.renkan.models.Space;
 import org.iri_research.renkan.repositories.SpacesRepository;
+import org.iri_research.renkan.rest.RestApplication;
 import org.iri_research.renkan.rest.SpacesResource;
 import org.joda.time.DateTime;
 import org.joda.time.format.DateTimeFormatter;
@@ -39,6 +38,7 @@
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.datatype.joda.JodaModule;
 
 @RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration("rest-context.xml")
@@ -51,7 +51,7 @@
 
     private Map<String, Space> spacesList = new HashMap<String, Space>();
     private String firstSpaceUUID = null;
-
+    
     public SpaceRestTest() {
     }
 
@@ -70,10 +70,8 @@
 
     @Override
     protected Application configure() {
-        ResourceConfig rc = new ResourceConfig()
-                .packages("org.iri_research.renkan.rest")
-                .register(SpringLifecycleListener.class)
-                .register(RequestContextFilter.class)
+        TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+        ResourceConfig rc = new RestApplication()
                 .property("contextConfigLocation",
                         "classpath:/org/iri_research/renkan/test/rest/rest-context.xml");
         rc.setApplicationName("rest");
@@ -85,7 +83,7 @@
 
         logger.debug("Setup");
         spacesRepository.deleteAll();
-        Date creationDate = new Date();
+        DateTime creationDate = new DateTime();
         this.firstSpaceUUID = UUID.randomUUID().toString();
         Space testSpace = new Space(firstSpaceUUID, "test", "Test space", "{}",
                 "http://ldt.iri.centrepompidou.fr", "#ababab", "test_user",
@@ -124,7 +122,8 @@
                 "The length of the space list resp. string must be > 0",
                 respString.length() > 0);
 
-        ObjectMapper mapper = new ObjectMapper();
+        ObjectMapper mapper = getObjectMapper();
+        
         JsonNode spacesList = mapper.readTree(respString);
 
         Assert.assertTrue("The spaceList must be an array",
@@ -154,7 +153,7 @@
         String respString = WebTarget.path("spaces").request()
                 .get(String.class);
         logger.debug("RESPONSE : " + respString);
-        ObjectMapper mapper = new ObjectMapper();
+        ObjectMapper mapper = getObjectMapper();
         JsonNode spacesList = mapper.readTree(respString);
 
         for (JsonNode jsonNode : spacesList) {
@@ -178,7 +177,7 @@
         String respString = WebTarget.path("spaces").request()
                 .get(String.class);
         logger.debug("RESPONSE : " + respString);
-        ObjectMapper mapper = new ObjectMapper();
+        ObjectMapper mapper = getObjectMapper();
         JsonNode spacesList = mapper.readTree(respString);
 
         for (JsonNode jsonNode : spacesList) {
@@ -203,7 +202,7 @@
         String respString = WebTarget.path("spaces").request()
                 .get(String.class);
         logger.debug("RESPONSE : " + respString);
-        ObjectMapper mapper = new ObjectMapper();
+        ObjectMapper mapper = getObjectMapper();
         JsonNode spacesList = mapper.readTree(respString);
 
         for (JsonNode jsonNode : spacesList) {
@@ -227,7 +226,8 @@
         String respString = WebTarget.path("spaces").request()
                 .get(String.class);
         logger.debug("RESPONSE : " + respString);
-        ObjectMapper mapper = new ObjectMapper();
+        ObjectMapper mapper = getObjectMapper();
+        mapper.registerModule(new JodaModule());
         JsonNode spacesList = mapper.readTree(respString);
 
         for (JsonNode jsonNode : spacesList) {
@@ -251,7 +251,8 @@
         String respString = WebTarget.path("spaces").request()
                 .get(String.class);
         logger.debug("RESPONSE : " + respString);
-        ObjectMapper mapper = new ObjectMapper();
+        ObjectMapper mapper = getObjectMapper();
+        
         JsonNode spacesList = mapper.readTree(respString);
 
         for (JsonNode jsonNode : spacesList) {
@@ -269,6 +270,12 @@
 
     }
 
+    private ObjectMapper getObjectMapper() {
+        ObjectMapper mapper = new ObjectMapper();
+        mapper.registerModule(new JodaModule());
+        return mapper;
+    }
+
     @Test
     public void testCreatedBy() throws JsonProcessingException, IOException {
 
@@ -276,7 +283,7 @@
         String respString = WebTarget.path("spaces").request()
                 .get(String.class);
         logger.debug("RESPONSE : " + respString);
-        ObjectMapper mapper = new ObjectMapper();
+        ObjectMapper mapper = getObjectMapper();
         JsonNode spacesList = mapper.readTree(respString);
 
         for (JsonNode jsonNode : spacesList) {
@@ -301,7 +308,7 @@
         String respString = WebTarget.path("spaces").request()
                 .get(String.class);
         logger.debug("RESPONSE : " + respString);
-        ObjectMapper mapper = new ObjectMapper();
+        ObjectMapper mapper = getObjectMapper();
         JsonNode spacesList = mapper.readTree(respString);
 
         for (JsonNode jsonNode : spacesList) {
@@ -317,7 +324,7 @@
             DateTime date = fmt.parseDateTime(dateStr);
 
             Assert.assertEquals("Created date must be the same",
-                    space.getCreated(), date.toDate());
+                    space.getCreated(), date);
 
         }
 
@@ -330,7 +337,7 @@
         String respString = WebTarget.path("spaces").request()
                 .get(String.class);
         logger.debug("RESPONSE : " + respString);
-        ObjectMapper mapper = new ObjectMapper();
+        ObjectMapper mapper = getObjectMapper();
         JsonNode spacesList = mapper.readTree(respString);
 
         for (JsonNode jsonNode : spacesList) {
@@ -355,7 +362,7 @@
         String respString = WebTarget.path("spaces").path(this.firstSpaceUUID)
                 .request().accept(MediaType.APPLICATION_JSON).get(String.class);
         logger.debug("RESPONSE : " + respString);
-        ObjectMapper mapper = new ObjectMapper();
+        ObjectMapper mapper = getObjectMapper();
         JsonNode jsonNode = mapper.readTree(respString);
 
         String id = jsonNode.get("id").asText();
@@ -370,7 +377,7 @@
         DateTime date = fmt.parseDateTime(dateStr);
 
         Assert.assertEquals("Created date must be the same",
-                space.getCreated(), date.toDate());
+                space.getCreated(), date);
 
     }
 
@@ -382,7 +389,7 @@
         String respString = WebTarget.path("spaces").path(this.firstSpaceUUID)
                 .request().accept(MediaType.APPLICATION_JSON).get(String.class);
         logger.debug("RESPONSE : " + respString);
-        ObjectMapper mapper = new ObjectMapper();
+        ObjectMapper mapper = getObjectMapper();
         JsonNode jsonNode = mapper.readTree(respString);
 
         Assert.assertTrue("the space must have a title",
@@ -402,7 +409,7 @@
         String respString = WebTarget.path("spaces").path(this.firstSpaceUUID)
                 .request().accept(MediaType.APPLICATION_JSON).get(String.class);
         logger.debug("RESPONSE : " + respString);
-        ObjectMapper mapper = new ObjectMapper();
+        ObjectMapper mapper = getObjectMapper();
         JsonNode jsonNode = mapper.readTree(respString);
 
         Assert.assertTrue("the space must have a description",
@@ -421,7 +428,7 @@
         String respString = WebTarget.path("spaces").path(this.firstSpaceUUID)
                 .request().accept(MediaType.APPLICATION_JSON).get(String.class);
         logger.debug("RESPONSE : " + respString);
-        ObjectMapper mapper = new ObjectMapper();
+        ObjectMapper mapper = getObjectMapper();
         JsonNode jsonNode = mapper.readTree(respString);
 
         Assert.assertTrue("the space must have a uri",
@@ -439,7 +446,7 @@
         String respString = WebTarget.path("spaces").path(this.firstSpaceUUID)
                 .request().accept(MediaType.APPLICATION_JSON).get(String.class);
         logger.debug("RESPONSE : " + respString);
-        ObjectMapper mapper = new ObjectMapper();
+        ObjectMapper mapper = getObjectMapper();
         JsonNode jsonNode = mapper.readTree(respString);
 
         Assert.assertTrue("the space must have a color",
@@ -459,7 +466,7 @@
         String respString = WebTarget.path("spaces").path(this.firstSpaceUUID)
                 .request().accept(MediaType.APPLICATION_JSON).get(String.class);
         logger.debug("RESPONSE : " + respString);
-        ObjectMapper mapper = new ObjectMapper();
+        ObjectMapper mapper = getObjectMapper();
         JsonNode jsonNode = mapper.readTree(respString);
 
         Assert.assertTrue("the space must have a bin_config",
@@ -479,7 +486,7 @@
         String respString = WebTarget.path("spaces").path(this.firstSpaceUUID)
                 .request().accept(MediaType.APPLICATION_JSON).get(String.class);
         logger.debug("RESPONSE : " + respString);
-        ObjectMapper mapper = new ObjectMapper();
+        ObjectMapper mapper = getObjectMapper();
         JsonNode jsonNode = mapper.readTree(respString);
 
         Assert.assertTrue("the space must have a created_by",
@@ -498,7 +505,7 @@
         String respString = WebTarget.path("spaces").path(this.firstSpaceUUID)
                 .request().accept(MediaType.APPLICATION_JSON).get(String.class);
         logger.debug("RESPONSE : " + respString);
-        ObjectMapper mapper = new ObjectMapper();
+        ObjectMapper mapper = getObjectMapper();
         JsonNode jsonNode = mapper.readTree(respString);
 
         Assert.assertTrue("the space must have a image",
@@ -518,6 +525,7 @@
         String color = "#bcbcbc";
         String image = "http://ldt.iri.centrepompidou.fr/test_post/image";
         String created = "2013-01-01T01:01:01.001+0000";
+        String expectedCreated = "2013-01-01T01:01:01.001Z";
         String bin_config = "{name: 'test_post_config'}";
         String created_by = "test_user_post";
 
@@ -540,7 +548,7 @@
         Assert.assertTrue("Resp must be application/json", resp.getMediaType()
                 .isCompatible(MediaType.APPLICATION_JSON_TYPE));
 
-        ObjectMapper mapper = new ObjectMapper();
+        ObjectMapper mapper = getObjectMapper();
         JsonNode objNode = mapper.readTree(respStr);
 
         Assert.assertTrue("the space must have an id", objNode.hasNonNull("id"));
@@ -585,8 +593,8 @@
         Assert.assertTrue("the space must have a created",
                 objNode.hasNonNull("created"));
         String createdStr = objNode.get("created").asText();
-        Assert.assertEquals("space created must be equals to " + created,
-                created, createdStr);
+        Assert.assertEquals("space created must be equals to " + expectedCreated,
+                expectedCreated, createdStr);
 
         // object must be created
         Space sp = this.spacesRepository.findOne(idStr);
@@ -608,7 +616,7 @@
         DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
         DateTime created_date = fmt.parseDateTime(created);
         Assert.assertEquals("space created must be equals to " + created,
-                created_date.toDate(), sp.getCreated());
+                created_date, sp.getCreated());
 
     }
 
@@ -701,7 +709,7 @@
         DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
         DateTime created_date = fmt.parseDateTime(created);
         Assert.assertEquals("space created must be equals to " + created,
-                created_date.toDate(), sp.getCreated());
+                created_date, sp.getCreated());
 
     }
 
@@ -813,7 +821,7 @@
 
         String jsonStr = respStr.substring("callback_func(".length(),
                 respStr.length() - 1);
-        ObjectMapper mapper = new ObjectMapper();
+        ObjectMapper mapper = getObjectMapper();
         JsonNode jsonNode = mapper.readTree(jsonStr);
 
         Space space = this.spacesList.get(this.firstSpaceUUID);
@@ -830,7 +838,7 @@
         DateTime date = fmt.parseDateTime(dateStr);
 
         Assert.assertEquals("Created date must be the same",
-                space.getCreated(), date.toDate());
+                space.getCreated(), date);
 
         Assert.assertEquals("title must be the same", space.getTitle(),
                 jsonNode.get("title").asText());
@@ -856,7 +864,7 @@
 
         String jsonStr = respStr.substring("callback_func(".length(),
                 respStr.length() - 1);
-        ObjectMapper mapper = new ObjectMapper();
+        ObjectMapper mapper = getObjectMapper();
         JsonNode jsonNode = mapper.readTree(jsonStr);
 
         Space space = this.spacesList.get(this.firstSpaceUUID);
@@ -873,7 +881,7 @@
         DateTime date = fmt.parseDateTime(dateStr);
 
         Assert.assertEquals("Created date must be the same",
-                space.getCreated(), date.toDate());
+                space.getCreated(), date);
 
         Assert.assertEquals("title must be the same", space.getTitle(),
                 jsonNode.get("title").asText());
--- a/server/src/test/resources/org/iri_research/renkan/test/controller/controller-context.xml	Thu Nov 07 10:42:18 2013 +0100
+++ b/server/src/test/resources/org/iri_research/renkan/test/controller/controller-context.xml	Fri Nov 15 09:34:41 2013 +0100
@@ -13,6 +13,10 @@
     <!-- Configures the annotation-driven Spring MVC Controller programming model.
     Note that, with Spring 3.0, this tag works in Servlet MVC only!  -->
 
+    <bean class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder" id="renkanPasswordEncoder">
+        <constructor-arg name="strength" value="10" type="int"/>
+    </bean>
+
     <!-- Loads MongoDB configuraton -->
     <import resource="mongo-config.xml"/>