Repository: eclipse/leshan
Pull request #180 (2016-09-27 14:14:08)

Add profile to run integrations tests with Redis store simplementation
To run the the integration-tests with redis implementation :

```
mvn clean install -Predis
```
or 
```
mvn clean install -Predis -Dredis.uri="redis://127.0.0.1:6379"   
```


Patch:
diff --git a/leshan-server-cluster/src/main/java/org/eclipse/leshan/server/demo/cluster/RedisSecurityRegistry.java b/leshan-server-cluster/src/main/java/org/eclipse/leshan/server/demo/cluster/RedisSecurityRegistry.java
index f6b9e1c6..cbce6913 100644
--- a/leshan-server-cluster/src/main/java/org/eclipse/leshan/server/demo/cluster/RedisSecurityRegistry.java
+++ b/leshan-server-cluster/src/main/java/org/eclipse/leshan/server/demo/cluster/RedisSecurityRegistry.java
@@ -135,13 +135,16 @@ public class RedisSecurityRegistry implements SecurityRegistry {
         try (Jedis j = pool.getResource()) {
             byte[] data = j.get((SEC_EP + endpoint).getBytes());
 
-            SecurityInfo info = deserialize(data);
-            if (info.getIdentity() != null) {
-                j.hdel(PSKID_SEC.getBytes(), info.getIdentity().getBytes());
+            if (data != null) {
+                SecurityInfo info = deserialize(data);
+                if (info.getIdentity() != null) {
+                    j.hdel(PSKID_SEC.getBytes(), info.getIdentity().getBytes());
+                }
+                j.del((SEC_EP + endpoint).getBytes());
+                return info;
             }
-            j.del((SEC_EP + endpoint).getBytes());
-            return info;
         }
+        return null;
     }
 
     @Override
diff --git a/pom.xml b/pom.xml
index 973e4256..980d9204 100644
--- a/pom.xml
+++ b/pom.xml
@@ -108,6 +108,7 @@ Contributors:
         <log4j.version>2.1</log4j.version>
         <slf4j.api.version>1.7.10</slf4j.api.version>
         <jetty.version>9.1.4.v20140401</jetty.version>
+        <test.exclusion.pattern>**/Redis*.java</test.exclusion.pattern>
     </properties>
 
     <distributionManagement>
@@ -128,6 +129,12 @@ Contributors:
                 <module>leshan-all</module>
             </modules>
         </profile>
+        <profile>
+          <id>redis</id>
+          <properties>
+                <test.exclusion.pattern>nothing</test.exclusion.pattern>
+          </properties>
+        </profile>
         <profile>
             <!-- this profile generate all the needed artifact and signatures needed, then release it on maven central -->
             <id>release</id>


Test patch:
diff --git a/leshan-core/src/test/java/org/eclipse/leshan/LinkObjectTest.java b/leshan-core/src/test/java/org/eclipse/leshan/LinkObjectTest.java
index 05298bc7..3b43752b 100644
--- a/leshan-core/src/test/java/org/eclipse/leshan/LinkObjectTest.java
+++ b/leshan-core/src/test/java/org/eclipse/leshan/LinkObjectTest.java
@@ -124,7 +124,6 @@ public class LinkObjectTest {
 
         LinkObject[] input = new LinkObject[] { obj1, obj2 };
         String strObjs = LinkObject.serialize(input);
-        System.out.println(strObjs);
         LinkObject[] output = LinkObject.parse(strObjs.getBytes());
 
         Assert.assertArrayEquals(input, output);
diff --git a/leshan-integration-tests/pom.xml b/leshan-integration-tests/pom.xml
index 9ae30501..b5f51f2e 100644
--- a/leshan-integration-tests/pom.xml
+++ b/leshan-integration-tests/pom.xml
@@ -32,6 +32,10 @@ Contributors:
             <groupId>org.eclipse.leshan</groupId>
             <artifactId>leshan-server-cf</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.eclipse.leshan</groupId>
+            <artifactId>leshan-server-cluster</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.eclipse.leshan</groupId>
             <artifactId>leshan-client-cf</artifactId>
@@ -61,8 +65,16 @@ Contributors:
                             src/test/resources/logging.properties
                         </java.util.logging.config.file>
                     </systemPropertyVariables>
+                    <excludes>
+                        <exclude>${test.exclusion.pattern}</exclude>
+                    </excludes>
+                    <environmentVariables>
+                        <REDIS_URI>${redis.uri}</REDIS_URI>
+                    </environmentVariables>
                 </configuration>
             </plugin>
         </plugins>
     </build>
+    
+    
 </project>
diff --git a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/BootstrapIntegrationTestHelper.java b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/BootstrapIntegrationTestHelper.java
index 40bfd8ee..8acf1ec3 100644
--- a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/BootstrapIntegrationTestHelper.java
+++ b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/BootstrapIntegrationTestHelper.java
@@ -46,9 +46,9 @@ import org.eclipse.leshan.util.Hex;
  */
 public class BootstrapIntegrationTestHelper extends IntegrationTestHelper {
 
-    // public static final String SECURE_ENDPOINT_IDENTIFIER = "secureclient";
-    public static final String SECURE_PSK_ID = "Client_identity";
-    public static final byte[] SECURE_PSK_KEY = Hex.decodeHex("73656372657450534b".toCharArray());
+    public static final String GOOD_PSK_ID = "Good_Client_identity";
+    public static final byte[] GOOD_PSK_KEY = Hex.decodeHex("73656372657450534b".toCharArray());
+    public static final byte[] BAD_PSK_KEY = Hex.decodeHex("010101010101010101".toCharArray());
 
     LwM2mBootstrapServerImpl bootstrapServer;
 
@@ -97,54 +97,47 @@ public class BootstrapIntegrationTestHelper extends IntegrationTestHelper {
     }
 
     public void createClient() {
-        ObjectsInitializer initializer = new ObjectsInitializer();
-
-        // set only the bootstrap server instance (security)
+        // Create Security Object (with bootstrap server only)
         String bsUrl = "coap://" + bootstrapServer.getNonSecureAddress().getHostString() + ":"
                 + bootstrapServer.getNonSecureAddress().getPort();
-
         Security security = new Security(bsUrl, true, 3, new byte[0], new byte[0], new byte[0], 12345);
 
-        initializer.setInstancesForObject(LwM2mId.SECURITY, security);
-
-        initializer.setInstancesForObject(LwM2mId.DEVICE,
-                new Device("Eclipse Leshan", IntegrationTestHelper.MODEL_NUMBER, "12345", "U"));
-        List<LwM2mObjectEnabler> objects = initializer.createMandatory();
-        objects.add(initializer.create(2));
-
-        LeshanClientBuilder builder = new LeshanClientBuilder(IntegrationTestHelper.ENDPOINT_IDENTIFIER);
-        builder.setObjects(objects);
-        client = builder.build();
+        createClient(security);
     }
 
     public void createPSKClient(String pskIdentity, byte[] pskKey) {
-        ObjectsInitializer initializer = new ObjectsInitializer();
 
+        // Create Security Object (with bootstrap server only)
         String bsUrl = "coaps://" + bootstrapServer.getSecureAddress().getHostString() + ":"
                 + bootstrapServer.getSecureAddress().getPort();
-
         byte[] pskId = pskIdentity.getBytes(Charsets.UTF_8);
-
         Security security = Security.pskBootstrap(bsUrl, pskId, pskKey);
 
-        initializer.setInstancesForObject(LwM2mId.SECURITY, security);
+        createClient(security);
+    }
 
+    private void createClient(Security security) {
+        ObjectsInitializer initializer = new ObjectsInitializer();
+
+        // Initialize LWM2M Object Tree
+        initializer.setInstancesForObject(LwM2mId.SECURITY, security);
         initializer.setInstancesForObject(LwM2mId.DEVICE,
                 new Device("Eclipse Leshan", IntegrationTestHelper.MODEL_NUMBER, "12345", "U"));
         List<LwM2mObjectEnabler> objects = initializer.createMandatory();
         objects.add(initializer.create(2));
 
-        LeshanClientBuilder builder = new LeshanClientBuilder(ENDPOINT_IDENTIFIER);
+        // Create Leshan Client
+        LeshanClientBuilder builder = new LeshanClientBuilder(getCurrentEndpoint());
         builder.setObjects(objects);
         client = builder.build();
     }
 
-    public static BootstrapSecurityStore bsSecurityStore() {
+    public BootstrapSecurityStore bsSecurityStore() {
 
         return new BootstrapSecurityStore() {
             @Override
             public SecurityInfo getByIdentity(String identity) {
-                if (BootstrapIntegrationTestHelper.SECURE_PSK_ID.equals(identity)) {
+                if (BootstrapIntegrationTestHelper.GOOD_PSK_ID.equals(identity)) {
                     return pskSecurityInfo();
                 } else {
                     return null;
@@ -153,21 +146,19 @@ public class BootstrapIntegrationTestHelper extends IntegrationTestHelper {
 
             @Override
             public List<SecurityInfo> getAllByEndpoint(String endpoint) {
-                if (IntegrationTestHelper.ENDPOINT_IDENTIFIER.equals(endpoint)) {
+                if (getCurrentEndpoint().equals(endpoint)) {
                     SecurityInfo info = pskSecurityInfo();
                     return Arrays.asList(info);
                 } else {
                     return Arrays.asList();
                 }
-
             }
-
         };
     }
 
-    public static SecurityInfo pskSecurityInfo() {
-        SecurityInfo info = SecurityInfo.newPreSharedKeyInfo(BootstrapIntegrationTestHelper.ENDPOINT_IDENTIFIER,
-                BootstrapIntegrationTestHelper.SECURE_PSK_ID, BootstrapIntegrationTestHelper.SECURE_PSK_KEY);
+    public SecurityInfo pskSecurityInfo() {
+        SecurityInfo info = SecurityInfo.newPreSharedKeyInfo(getCurrentEndpoint(),
+                BootstrapIntegrationTestHelper.GOOD_PSK_ID, BootstrapIntegrationTestHelper.GOOD_PSK_KEY);
         return info;
     }
 
@@ -186,4 +177,9 @@ public class BootstrapIntegrationTestHelper extends IntegrationTestHelper {
         };
     }
 
+    @Override
+    public void dispose() {
+        super.dispose();
+        server.getSecurityRegistry().remove(getCurrentEndpoint());
+    }
 }
diff --git a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/BootstrapTest.java b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/BootstrapTest.java
index 54ebf7a8..81890e4c 100644
--- a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/BootstrapTest.java
+++ b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/BootstrapTest.java
@@ -15,11 +15,8 @@
  *******************************************************************************/
 package org.eclipse.leshan.integration.tests;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.eclipse.leshan.integration.tests.BootstrapIntegrationTestHelper.*;
 
-import org.eclipse.leshan.util.Hex;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -30,66 +27,71 @@ public class BootstrapTest {
 
     @Before
     public void start() {
-        // DM server
-        helper.createServer();
+        helper.initialize();
+        helper.createServer(); // DM server
         helper.server.start();
-
     }
 
     @After
     public void stop() {
-
         helper.client.stop(true);
         helper.bootstrapServer.stop();
         helper.server.stop();
+        helper.dispose();
     }
 
     @Test
     public void bootstrap() {
-        // Bootstrap server
+        // Create and start bootstrap server
         helper.createBootstrapServer(null);
         helper.bootstrapServer.start();
 
+        // Create Client and check it is not already registered
         helper.createClient();
-        helper.client.start();
+        helper.assertClientNotRegisterered();
 
+        // Start it and wait for registration
+        helper.client.start();
         helper.waitForRegistration(1);
 
         // check the client is registered
-        assertEquals(1, helper.server.getClientRegistry().allClients().size());
-        assertNotNull(helper.server.getClientRegistry().get(BootstrapIntegrationTestHelper.ENDPOINT_IDENTIFIER));
+        helper.assertClientRegisterered();
     }
 
     @Test
     public void bootstrapSecure() {
-
-        // Bootstrap server
-        helper.createBootstrapServer(BootstrapIntegrationTestHelper.bsSecurityStore());
+        // Create and start bootstrap server
+        helper.createBootstrapServer(helper.bsSecurityStore());
         helper.bootstrapServer.start();
 
-        helper.createPSKClient("Client_identity", Hex.decodeHex("73656372657450534b".toCharArray()));
-        helper.client.start();
+        // Create PSK Client and check it is not already registered
+        helper.createPSKClient(GOOD_PSK_ID, GOOD_PSK_KEY);
+        helper.assertClientNotRegisterered();
 
+        // Start it and wait for registration
+        helper.client.start();
         helper.waitForRegistration(1);
 
-        assertEquals(1, helper.server.getClientRegistry().allClients().size());
-        assertNotNull(helper.server.getClientRegistry().get(IntegrationTestHelper.ENDPOINT_IDENTIFIER));
+        // check the client is registered
+        helper.assertClientRegisterered();
     }
 
     @Test
     public void bootstrapSecureWithBadCredentials() {
-
-        // Bootstrap server
-        helper.createBootstrapServer(BootstrapIntegrationTestHelper.bsSecurityStore());
+        // Create and start bootstrap server
+        helper.createBootstrapServer(helper.bsSecurityStore());
         helper.bootstrapServer.start();
 
-        helper.createPSKClient("Client_identity", Hex.decodeHex("010101010101010101".toCharArray()));
-        helper.client.start();
+        // Create PSK Client with bad credentials and check it is not already registered
+        helper.createPSKClient(GOOD_PSK_ID, BAD_PSK_KEY);
+        helper.assertClientNotRegisterered();
 
+        // Start it and wait for registration
+        helper.client.start();
         helper.waitForRegistration(1);
 
-        assertEquals(0, helper.server.getClientRegistry().allClients().size());
-        assertNull(helper.server.getClientRegistry().get(IntegrationTestHelper.ENDPOINT_IDENTIFIER));
+        // check the client is registered
+        helper.assertClientNotRegisterered();
     }
 
 }
diff --git a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/CreateTest.java b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/CreateTest.java
index ea7bcf94..5f49def6 100644
--- a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/CreateTest.java
+++ b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/CreateTest.java
@@ -41,6 +41,7 @@ public class CreateTest {
 
     @Before
     public void start() {
+        helper.initialize();
         helper.createServer();
         helper.server.start();
         helper.createClient();
@@ -52,12 +53,13 @@ public class CreateTest {
     public void stop() {
         helper.client.stop(false);
         helper.server.stop();
+        helper.dispose();
     }
 
     @Test
     public void can_create_instance_of_object_without_instance_id() throws InterruptedException {
         // create ACL instance
-        CreateResponse response = helper.server.send(helper.getClient(), new CreateRequest(2,
+        CreateResponse response = helper.server.send(helper.getCurrentRegistration(), new CreateRequest(2,
                 new LwM2mResource[] { LwM2mSingleResource.newIntegerResource(0, 123) }));
 
         // verify result
@@ -65,7 +67,7 @@ public class CreateTest {
         assertEquals("2/0", response.getLocation());
 
         // create a second ACL instance
-        response = helper.server.send(helper.getClient(), new CreateRequest(2,
+        response = helper.server.send(helper.getCurrentRegistration(), new CreateRequest(2,
                 new LwM2mResource[] { LwM2mSingleResource.newIntegerResource(0, 123) }));
 
         // verify result
@@ -79,7 +81,7 @@ public class CreateTest {
         // create ACL instance
         LwM2mObjectInstance instance = new LwM2mObjectInstance(12,
                 Arrays.<LwM2mResource> asList(LwM2mSingleResource.newIntegerResource(3, 123)));
-        CreateResponse response = helper.server.send(helper.getClient(), new CreateRequest(2, instance));
+        CreateResponse response = helper.server.send(helper.getCurrentRegistration(), new CreateRequest(2, instance));
 
         // verify result
         assertEquals(ResponseCode.CREATED, response.getCode());
@@ -91,7 +93,7 @@ public class CreateTest {
         // create ACL instance
         LwM2mObjectInstance instance = new LwM2mObjectInstance(12,
                 Arrays.<LwM2mResource> asList(LwM2mSingleResource.newIntegerResource(3, 123)));
-        CreateResponse response = helper.server.send(helper.getClient(),
+        CreateResponse response = helper.server.send(helper.getCurrentRegistration(),
                 new CreateRequest(ContentFormat.JSON, 2, instance));
 
         // verify result
@@ -102,7 +104,8 @@ public class CreateTest {
     @Test
     public void cannot_create_instance_of_object() throws InterruptedException {
         // try to create an instance of object 50
-        CreateResponse response = helper.server.send(helper.getClient(), new CreateRequest(50, new LwM2mResource[0]));
+        CreateResponse response = helper.server.send(helper.getCurrentRegistration(),
+                new CreateRequest(50, new LwM2mResource[0]));
 
         // verify result
         assertEquals(ResponseCode.NOT_FOUND, response.getCode());
@@ -115,14 +118,15 @@ public class CreateTest {
     @Test
     public void cannot_create_instance_without_all_required_resources() throws InterruptedException {
         // create ACL instance
-        CreateResponse response = helper.server.send(helper.getClient(), new CreateRequest(2, new LwM2mResource[0]));
+        CreateResponse response = helper.server.send(helper.getCurrentRegistration(),
+                new CreateRequest(2, new LwM2mResource[0]));
 
         // verify result
         assertEquals(ResponseCode.BAD_REQUEST, response.getCode());
 
         // try to read to check if the instance is not created
         // client registration
-        ReadResponse readResponse = helper.server.send(helper.getClient(), new ReadRequest(2, 0));
+        ReadResponse readResponse = helper.server.send(helper.getCurrentRegistration(), new ReadRequest(2, 0));
         assertEquals(ResponseCode.NOT_FOUND, readResponse.getCode());
     }
 
@@ -134,14 +138,14 @@ public class CreateTest {
         LwM2mObjectInstance instance = new LwM2mObjectInstance(0, Arrays.<LwM2mResource> asList(
                 LwM2mSingleResource.newIntegerResource(3, 123), LwM2mSingleResource.newIntegerResource(50, 123)));
         CreateRequest request = new CreateRequest(2, instance);
-        CreateResponse response = helper.server.send(helper.getClient(), request);
+        CreateResponse response = helper.server.send(helper.getCurrentRegistration(), request);
 
         // verify result
         assertEquals(ResponseCode.BAD_REQUEST, response.getCode());
 
         // try to read to check if the instance is not created
         // client registration
-        ReadResponse readResponse = helper.server.send(helper.getClient(), new ReadRequest(2, 0));
+        ReadResponse readResponse = helper.server.send(helper.getCurrentRegistration(), new ReadRequest(2, 0));
         assertEquals(ResponseCode.NOT_FOUND, readResponse.getCode());
     }
 
@@ -155,7 +159,7 @@ public class CreateTest {
     @Test
     public void cannot_create_mandatory_single_object() throws InterruptedException {
         // try to create another instance of device object
-        CreateResponse response = helper.server.send(helper.getClient(),
+        CreateResponse response = helper.server.send(helper.getCurrentRegistration(),
                 new CreateRequest(3, new LwM2mResource[] { LwM2mSingleResource.newIntegerResource(3, 123) }));
 
         // verify result
@@ -164,7 +168,7 @@ public class CreateTest {
 
     @Test
     public void cannot_create_instance_of_security_object() throws InterruptedException {
-        CreateResponse response = helper.server.send(helper.getClient(),
+        CreateResponse response = helper.server.send(helper.getCurrentRegistration(),
                 new CreateRequest(0, new LwM2mResource[] { LwM2mSingleResource.newStringResource(0, "new.dest") }));
 
         // verify result
diff --git a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/DeleteTest.java b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/DeleteTest.java
index 2521f80a..ad58a729 100644
--- a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/DeleteTest.java
+++ b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/DeleteTest.java
@@ -39,6 +39,7 @@ public class DeleteTest {
 
     @Before
     public void start() {
+        helper.initialize();
         helper.createServer();
         helper.server.start();
         helper.createClient();
@@ -50,18 +51,19 @@ public class DeleteTest {
     public void stop() {
         helper.client.stop(false);
         helper.server.stop();
+        helper.dispose();
     }
 
     @Test
     public void delete_created_object_instance() throws InterruptedException {
         // create ACL instance
         helper.server.send(
-                helper.getClient(),
+                helper.getCurrentRegistration(),
                 new CreateRequest(2, new LwM2mObjectInstance(0, Arrays.asList(new LwM2mResource[] { LwM2mSingleResource
                         .newIntegerResource(0, 123) }))));
 
         // try to delete this instance
-        DeleteResponse deleteResponse = helper.server.send(helper.getClient(), new DeleteRequest(2, 0));
+        DeleteResponse deleteResponse = helper.server.send(helper.getCurrentRegistration(), new DeleteRequest(2, 0));
 
         // verify result
         assertEquals(ResponseCode.DELETED, deleteResponse.getCode());
@@ -71,12 +73,12 @@ public class DeleteTest {
     public void cannot_delete_resource_of_created_object_instance() throws InterruptedException {
         // create ACL instance
         helper.server.send(
-                helper.getClient(),
+                helper.getCurrentRegistration(),
                 new CreateRequest(2, new LwM2mObjectInstance(0, Arrays.asList(new LwM2mResource[] { LwM2mSingleResource
                         .newIntegerResource(0, 123) }))));
 
         // try to delete this instance
-        DeleteResponse deleteResponse = helper.server.send(helper.getClient(), new DeleteRequest("/2/0/0"));
+        DeleteResponse deleteResponse = helper.server.send(helper.getCurrentRegistration(), new DeleteRequest("/2/0/0"));
 
         // verify result
         assertEquals(ResponseCode.METHOD_NOT_ALLOWED, deleteResponse.getCode());
@@ -85,7 +87,7 @@ public class DeleteTest {
     @Test
     public void cannot_delete_unknown_object_instance() throws InterruptedException {
         // try to create an instance of object 50
-        DeleteResponse response = helper.server.send(helper.getClient(), new DeleteRequest(2, 0));
+        DeleteResponse response = helper.server.send(helper.getCurrentRegistration(), new DeleteRequest(2, 0));
 
         // verify result
         assertEquals(ResponseCode.NOT_FOUND, response.getCode());
@@ -94,7 +96,7 @@ public class DeleteTest {
     @Test
     public void cannot_delete_single_manadatory_object_instance() throws InterruptedException {
         // try to create an instance of object 50
-        DeleteResponse response = helper.server.send(helper.getClient(), new DeleteRequest(3, 0));
+        DeleteResponse response = helper.server.send(helper.getCurrentRegistration(), new DeleteRequest(3, 0));
 
         // verify result
         assertEquals(ResponseCode.METHOD_NOT_ALLOWED, response.getCode());
@@ -102,7 +104,7 @@ public class DeleteTest {
 
     @Test
     public void cannot_delete_security_object_instance() throws InterruptedException {
-        DeleteResponse response = helper.server.send(helper.getClient(), new DeleteRequest(0, 0));
+        DeleteResponse response = helper.server.send(helper.getCurrentRegistration(), new DeleteRequest(0, 0));
 
         // verify result
         assertEquals(ResponseCode.NOT_FOUND, response.getCode());
diff --git a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/DiscoverTest.java b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/DiscoverTest.java
index f01b363a..50b749de 100644
--- a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/DiscoverTest.java
+++ b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/DiscoverTest.java
@@ -16,10 +16,8 @@
 
 package org.eclipse.leshan.integration.tests;
 
-import static org.eclipse.leshan.ResponseCode.CONTENT;
-import static org.eclipse.leshan.ResponseCode.NOT_FOUND;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
+import static org.eclipse.leshan.ResponseCode.*;
+import static org.junit.Assert.*;
 
 import org.eclipse.leshan.LinkObject;
 import org.eclipse.leshan.core.request.DiscoverRequest;
@@ -34,6 +32,7 @@ public class DiscoverTest {
 
     @Before
     public void start() {
+        helper.initialize();
         helper.createServer();
         helper.server.start();
         helper.createClient();
@@ -50,7 +49,7 @@ public class DiscoverTest {
     @Test
     public void can_discover_object() throws InterruptedException {
         // read ACL object
-        DiscoverResponse response = helper.server.send(helper.getClient(), new DiscoverRequest(2));
+        DiscoverResponse response = helper.server.send(helper.getCurrentRegistration(), new DiscoverRequest(2));
 
         // verify result
         assertEquals(CONTENT, response.getCode());
@@ -62,7 +61,7 @@ public class DiscoverTest {
     @Test
     public void cant_discover_non_existent_object() throws InterruptedException {
         // read ACL object
-        DiscoverResponse response = helper.server.send(helper.getClient(), new DiscoverRequest(4));
+        DiscoverResponse response = helper.server.send(helper.getCurrentRegistration(), new DiscoverRequest(4));
 
         // verify result
         assertEquals(NOT_FOUND, response.getCode());
@@ -71,7 +70,7 @@ public class DiscoverTest {
     @Test
     public void can_discover_object_instance() throws InterruptedException {
         // read ACL object
-        DiscoverResponse response = helper.server.send(helper.getClient(), new DiscoverRequest(3, 0));
+        DiscoverResponse response = helper.server.send(helper.getCurrentRegistration(), new DiscoverRequest(3, 0));
 
         // verify result
         assertEquals(CONTENT, response.getCode());
@@ -83,7 +82,7 @@ public class DiscoverTest {
     @Test
     public void cant_discover_non_existent_instance() throws InterruptedException {
         // read ACL object
-        DiscoverResponse response = helper.server.send(helper.getClient(), new DiscoverRequest(3, 1));
+        DiscoverResponse response = helper.server.send(helper.getCurrentRegistration(), new DiscoverRequest(3, 1));
 
         // verify result
         assertEquals(NOT_FOUND, response.getCode());
@@ -92,7 +91,7 @@ public class DiscoverTest {
     @Test
     public void can_discover_resource() throws InterruptedException {
         // read ACL object
-        DiscoverResponse response = helper.server.send(helper.getClient(), new DiscoverRequest(3, 0, 0));
+        DiscoverResponse response = helper.server.send(helper.getCurrentRegistration(), new DiscoverRequest(3, 0, 0));
 
         // verify result
         assertEquals(CONTENT, response.getCode());
@@ -104,7 +103,7 @@ public class DiscoverTest {
     @Test
     public void cant_discover_resource_of_non_existent_object() throws InterruptedException {
         // read ACL object
-        DiscoverResponse response = helper.server.send(helper.getClient(), new DiscoverRequest(4, 0, 0));
+        DiscoverResponse response = helper.server.send(helper.getCurrentRegistration(), new DiscoverRequest(4, 0, 0));
 
         // verify result
         assertEquals(NOT_FOUND, response.getCode());
@@ -113,7 +112,7 @@ public class DiscoverTest {
     @Test
     public void cant_discover_resource_of_non_existent_instance() throws InterruptedException {
         // read ACL object
-        DiscoverResponse response = helper.server.send(helper.getClient(), new DiscoverRequest(3, 1, 0));
+        DiscoverResponse response = helper.server.send(helper.getCurrentRegistration(), new DiscoverRequest(3, 1, 0));
 
         // verify result
         assertEquals(NOT_FOUND, response.getCode());
@@ -122,7 +121,7 @@ public class DiscoverTest {
     @Test
     public void cant_discover_resource_of_non_existent_instance_and_resource() throws InterruptedException {
         // read ACL object
-        DiscoverResponse response = helper.server.send(helper.getClient(), new DiscoverRequest(3, 1, 20));
+        DiscoverResponse response = helper.server.send(helper.getCurrentRegistration(), new DiscoverRequest(3, 1, 20));
 
         // verify result
         assertEquals(NOT_FOUND, response.getCode());
@@ -131,7 +130,7 @@ public class DiscoverTest {
     @Test
     public void cant_discover_resource_of_non_existent_resource() throws InterruptedException {
         // read ACL object
-        DiscoverResponse response = helper.server.send(helper.getClient(), new DiscoverRequest(3, 0, 20));
+        DiscoverResponse response = helper.server.send(helper.getCurrentRegistration(), new DiscoverRequest(3, 0, 20));
 
         // verify result
         assertEquals(NOT_FOUND, response.getCode());
diff --git a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/ExecuteTest.java b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/ExecuteTest.java
index d111083e..ab07868a 100644
--- a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/ExecuteTest.java
+++ b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/ExecuteTest.java
@@ -33,6 +33,7 @@ public class ExecuteTest {
 
     @Before
     public void start() {
+        helper.initialize();
         helper.createServer();
         helper.server.start();
         helper.createClient();
@@ -44,12 +45,13 @@ public class ExecuteTest {
     public void stop() {
         helper.client.stop(false);
         helper.server.stop();
+        helper.dispose();
     }
 
     @Test
     public void cannot_execute_read_only_resource() throws InterruptedException {
         // execute manufacturer resource on device
-        ExecuteResponse response = helper.server.send(helper.getClient(), new ExecuteRequest(3, 0, 0));
+        ExecuteResponse response = helper.server.send(helper.getCurrentRegistration(), new ExecuteRequest(3, 0, 0));
 
         // verify result
         assertEquals(ResponseCode.METHOD_NOT_ALLOWED, response.getCode());
@@ -58,7 +60,7 @@ public class ExecuteTest {
     @Test
     public void cannot_execute_read_write_resource() throws InterruptedException {
         // execute current time resource on device
-        ExecuteResponse response = helper.server.send(helper.getClient(), new ExecuteRequest(3, 0, 13));
+        ExecuteResponse response = helper.server.send(helper.getCurrentRegistration(), new ExecuteRequest(3, 0, 13));
 
         // verify result
         assertEquals(ResponseCode.METHOD_NOT_ALLOWED, response.getCode());
@@ -68,7 +70,7 @@ public class ExecuteTest {
     public void cannot_execute_nonexisting_resource_on_existing_object() throws InterruptedException {
         final int nonExistingResourceId = 9999;
         // execute non existing resource on device
-        ExecuteResponse response = helper.server.send(helper.getClient(), new ExecuteRequest(3, 0,
+        ExecuteResponse response = helper.server.send(helper.getCurrentRegistration(), new ExecuteRequest(3, 0,
                 nonExistingResourceId));
 
         // verify result
@@ -79,7 +81,7 @@ public class ExecuteTest {
     public void cannot_execute_nonexisting_resource_on_non_existing_object() throws InterruptedException {
         final int nonExistingObjectId = 9999;
         ExecuteResponse response = helper.server
-                .send(helper.getClient(), new ExecuteRequest(nonExistingObjectId, 0, 0));
+                .send(helper.getCurrentRegistration(), new ExecuteRequest(nonExistingObjectId, 0, 0));
 
         // verify result
         assertEquals(ResponseCode.NOT_FOUND, response.getCode());
@@ -87,7 +89,7 @@ public class ExecuteTest {
 
     @Test
     public void cannot_execute_security_object() throws InterruptedException {
-        ExecuteResponse response = helper.server.send(helper.getClient(), new ExecuteRequest(0, 0, 0));
+        ExecuteResponse response = helper.server.send(helper.getCurrentRegistration(), new ExecuteRequest(0, 0, 0));
 
         // verify result
         assertEquals(ResponseCode.NOT_FOUND, response.getCode());
@@ -96,7 +98,7 @@ public class ExecuteTest {
     @Test
     public void can_execute_resource() throws InterruptedException {
         // execute reboot resource on device
-        ExecuteResponse response = helper.server.send(helper.getClient(), new ExecuteRequest(3, 0, 4));
+        ExecuteResponse response = helper.server.send(helper.getCurrentRegistration(), new ExecuteRequest(3, 0, 4));
 
         // verify result
         assertEquals(ResponseCode.CHANGED, response.getCode());
@@ -105,7 +107,7 @@ public class ExecuteTest {
     @Test
     public void can_execute_resource_with_parameters() throws InterruptedException {
         // execute reboot after 60 seconds on device
-        ExecuteResponse response = helper.server.send(helper.getClient(), new ExecuteRequest(3, 0, 4, "60"));
+        ExecuteResponse response = helper.server.send(helper.getCurrentRegistration(), new ExecuteRequest(3, 0, 4, "60"));
 
         // verify result
         assertEquals(ResponseCode.CHANGED, response.getCode());
diff --git a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/IntegrationTestHelper.java b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/IntegrationTestHelper.java
index cf6c576c..12680518 100644
--- a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/IntegrationTestHelper.java
+++ b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/IntegrationTestHelper.java
@@ -16,9 +16,12 @@
 
 package org.eclipse.leshan.integration.tests;
 
+import static org.junit.Assert.*;
+
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.util.List;
+import java.util.Random;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
@@ -51,8 +54,8 @@ import org.eclipse.leshan.server.model.StaticModelProvider;
  * 
  */
 public class IntegrationTestHelper {
-
-    static final String ENDPOINT_IDENTIFIER = "kdfflwmtm";
+    public static final Random r = new Random();
+    
     static final String MODEL_NUMBER = "IT-TEST-123";
     public static final long LIFETIME = 2;
 
@@ -67,10 +70,12 @@ public class IntegrationTestHelper {
     public static final int OBJLNK_SINGLE_INSTANCE_RESOURCE_ID = 7;
 
     LeshanServer server;
+
     LwM2mClient client;
-    Client last_registration;
+    String currentEndpointIdentifier;
 
     CountDownLatch registerLatch;
+    Client last_registration;
     CountDownLatch deregisterLatch;
     CountDownLatch updateLatch;
 
@@ -100,8 +105,15 @@ public class IntegrationTestHelper {
         return objectModels;
     }
 
-    public void createClient() {
+    public void initialize() {
+        currentEndpointIdentifier = "leshan_integration_test_" + r.nextInt();
+    }
+
+    public String getCurrentEndpoint() {
+        return currentEndpointIdentifier;
+    }
 
+    public void createClient() {
         // Create objects Enabler
         ObjectsInitializer initializer = new ObjectsInitializer(new LwM2mModel(createObjectModels()));
         initializer.setInstancesForObject(LwM2mId.SECURITY, Security.noSec(
@@ -122,7 +134,7 @@ public class IntegrationTestHelper {
         objects.addAll(initializer.create(2, 2000));
 
         // Build Client
-        LeshanClientBuilder builder = new LeshanClientBuilder(ENDPOINT_IDENTIFIER);
+        LeshanClientBuilder builder = new LeshanClientBuilder(currentEndpointIdentifier);
         builder.setObjects(objects);
         client = builder.build();
     }
@@ -152,21 +164,21 @@ public class IntegrationTestHelper {
         server.getClientRegistry().addListener(new ClientRegistryListener() {
             @Override
             public void updated(ClientUpdate update, Client clientUpdated) {
-                if (clientUpdated.getEndpoint().equals(ENDPOINT_IDENTIFIER)) {
+                if (clientUpdated.getEndpoint().equals(currentEndpointIdentifier)) {
                     updateLatch.countDown();
                 }
             }
 
             @Override
             public void unregistered(Client client) {
-                if (client.getEndpoint().equals(ENDPOINT_IDENTIFIER)) {
+                if (client.getEndpoint().equals(currentEndpointIdentifier)) {
                     deregisterLatch.countDown();
                 }
             }
 
             @Override
             public void registered(Client client) {
-                if (client.getEndpoint().equals(ENDPOINT_IDENTIFIER)) {
+                if (client.getEndpoint().equals(currentEndpointIdentifier)) {
                     last_registration = client;
                     registerLatch.countDown();
                 }
@@ -204,7 +216,26 @@ public class IntegrationTestHelper {
         }
     }
 
-    public Client getClient() {
-        return server.getClientRegistry().get(ENDPOINT_IDENTIFIER);
+    public Client getCurrentRegistration() {
+        return server.getClientRegistry().get(currentEndpointIdentifier);
+    }
+
+    public void deregisterClient() {
+        Client c = getCurrentRegistration();
+        if (c != null)
+            server.getClientRegistry().deregisterClient(c.getRegistrationId());
+    }
+
+    public void dispose() {
+        deregisterClient();
+        currentEndpointIdentifier = null;
+    }
+
+    public void assertClientRegisterered() {
+        assertNotNull(getCurrentRegistration());
+    }
+
+    public void assertClientNotRegisterered() {
+        assertNull(getCurrentRegistration());
     }
 }
diff --git a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/ObserveTest.java b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/ObserveTest.java
index 6ec21f65..60ff8f9f 100644
--- a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/ObserveTest.java
+++ b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/ObserveTest.java
@@ -16,8 +16,7 @@
 
 package org.eclipse.leshan.integration.tests;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
 
 import java.util.List;
 import java.util.concurrent.CountDownLatch;
@@ -44,10 +43,11 @@ import org.junit.Test;
 
 public class ObserveTest {
 
-    private IntegrationTestHelper helper = new IntegrationTestHelper();
+    protected IntegrationTestHelper helper = new IntegrationTestHelper();
 
     @Before
     public void start() {
+        helper.initialize();
         helper.createServer();
         helper.server.start();
         helper.createClient();
@@ -59,6 +59,7 @@ public class ObserveTest {
     public void stop() {
         helper.client.stop(false);
         helper.server.stop();
+        helper.dispose();
     }
 
     @Test
@@ -67,22 +68,22 @@ public class ObserveTest {
         helper.server.getObservationRegistry().addListener(listener);
 
         // observe device timezone
-        ObserveResponse observeResponse = helper.server.send(helper.getClient(), new ObserveRequest(3, 0, 15));
+        ObserveResponse observeResponse = helper.server.send(helper.getCurrentRegistration(), new ObserveRequest(3, 0, 15));
         assertEquals(ResponseCode.CONTENT, observeResponse.getCode());
 
         // an observation response should have been sent
         Observation observation = observeResponse.getObservation();
         assertEquals("/3/0/15", observation.getPath().toString());
-        assertEquals(helper.getClient().getRegistrationId(), observation.getRegistrationId());
+        assertEquals(helper.getCurrentRegistration().getRegistrationId(), observation.getRegistrationId());
 
         // write device timezone
-        LwM2mResponse writeResponse = helper.server.send(helper.getClient(),
+        LwM2mResponse writeResponse = helper.server.send(helper.getCurrentRegistration(),
                 new WriteRequest(3, 0, 15, "Europe/Paris"));
 
         // verify result
         listener.waitForNotification(2000);
         assertEquals(ResponseCode.CHANGED, writeResponse.getCode());
-        assertTrue(listener.receievedNotify().get());
+        assertTrue(listener.receivedNotify().get());
         assertEquals(LwM2mSingleResource.newStringResource(15, "Europe/Paris"), listener.getContent());
     }
 
@@ -92,26 +93,26 @@ public class ObserveTest {
         helper.server.getObservationRegistry().addListener(listener);
 
         // observe device timezone
-        ObserveResponse observeResponse = helper.server.send(helper.getClient(), new ObserveRequest(3, 0));
+        ObserveResponse observeResponse = helper.server.send(helper.getCurrentRegistration(), new ObserveRequest(3, 0));
         assertEquals(ResponseCode.CONTENT, observeResponse.getCode());
 
         // an observation response should have been sent
         Observation observation = observeResponse.getObservation();
         assertEquals("/3/0", observation.getPath().toString());
-        assertEquals(helper.getClient().getRegistrationId(), observation.getRegistrationId());
+        assertEquals(helper.getCurrentRegistration().getRegistrationId(), observation.getRegistrationId());
 
         // write device timezone
-        LwM2mResponse writeResponse = helper.server.send(helper.getClient(),
+        LwM2mResponse writeResponse = helper.server.send(helper.getCurrentRegistration(),
                 new WriteRequest(3, 0, 15, "Europe/Paris"));
 
         // verify result
         listener.waitForNotification(2000);
         assertEquals(ResponseCode.CHANGED, writeResponse.getCode());
-        assertTrue(listener.receievedNotify().get());
+        assertTrue(listener.receivedNotify().get());
         assertTrue(listener.getContent() instanceof LwM2mObjectInstance);
 
         // try to read the object instance for comparing
-        ReadResponse readResp = helper.server.send(helper.getClient(), new ReadRequest(3, 0));
+        ReadResponse readResp = helper.server.send(helper.getCurrentRegistration(), new ReadRequest(3, 0));
 
         assertEquals(readResp.getContent(), listener.getContent());
     }
@@ -122,26 +123,26 @@ public class ObserveTest {
         helper.server.getObservationRegistry().addListener(listener);
 
         // observe device timezone
-        ObserveResponse observeResponse = helper.server.send(helper.getClient(), new ObserveRequest(3));
+        ObserveResponse observeResponse = helper.server.send(helper.getCurrentRegistration(), new ObserveRequest(3));
         assertEquals(ResponseCode.CONTENT, observeResponse.getCode());
 
         // an observation response should have been sent
         Observation observation = observeResponse.getObservation();
         assertEquals("/3", observation.getPath().toString());
-        assertEquals(helper.getClient().getRegistrationId(), observation.getRegistrationId());
+        assertEquals(helper.getCurrentRegistration().getRegistrationId(), observation.getRegistrationId());
 
         // write device timezone
-        LwM2mResponse writeResponse = helper.server.send(helper.getClient(),
+        LwM2mResponse writeResponse = helper.server.send(helper.getCurrentRegistration(),
                 new WriteRequest(3, 0, 15, "Europe/Paris"));
 
         // verify result
         listener.waitForNotification(2000);
         assertEquals(ResponseCode.CHANGED, writeResponse.getCode());
-        assertTrue(listener.receievedNotify().get());
+        assertTrue(listener.receivedNotify().get());
         assertTrue(listener.getContent() instanceof LwM2mObject);
 
         // try to read the object for comparing
-        ReadResponse readResp = helper.server.send(helper.getClient(), new ReadRequest(3));
+        ReadResponse readResp = helper.server.send(helper.getCurrentRegistration(), new ReadRequest(3));
 
         assertEquals(readResp.getContent(), listener.getContent());
     }
@@ -169,7 +170,7 @@ public class ObserveTest {
         public void newObservation(final Observation observation) {
         }
 
-        public AtomicBoolean receievedNotify() {
+        public AtomicBoolean receivedNotify() {
             return receivedNotify;
         }
 
diff --git a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/QueueModeIntegrationTestHelper.java b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/QueueModeIntegrationTestHelper.java
index a2f4aca6..282852e1 100644
--- a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/QueueModeIntegrationTestHelper.java
+++ b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/QueueModeIntegrationTestHelper.java
@@ -168,13 +168,13 @@ public class QueueModeIntegrationTestHelper extends IntegrationTestHelper {
         enablers.add(initializer.create(2));
         enablers.add(initializer.create(3));
 
-        return new QueuedModeLeshanClient(ENDPOINT_IDENTIFIER, new InetSocketAddress(0), // localAddress
+        return new QueuedModeLeshanClient(getCurrentEndpoint(), new InetSocketAddress(0), // localAddress
                 new InetSocketAddress(0), // localSecureAddress
                 enablers);
     }
 
     @Override
-    public Client getClient() {
-        return server.getClientRegistry().get(ENDPOINT_IDENTIFIER);
+    public Client getCurrentRegistration() {
+        return server.getClientRegistry().get(getCurrentEndpoint());
     }
 }
diff --git a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/QueueModeTest.java b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/QueueModeTest.java
index 2a30ee53..b5b8474c 100644
--- a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/QueueModeTest.java
+++ b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/QueueModeTest.java
@@ -96,6 +96,7 @@ public class QueueModeTest {
     @Before
     public void start() {
         helper = new QueueModeIntegrationTestHelper();
+        helper.initialize();
         helper.createServer();
         helper.server.start();
         helper.createClient();
@@ -109,12 +110,13 @@ public class QueueModeTest {
         helper.client.stop(DEREGISTER);
         helper.server.getLwM2mRequestSender().removeResponseListener(responseListener);
         helper.server.stop();
+        helper.dispose();
     }
 
     @Test
     public void first_request_sent_immediately() throws Exception {
         createAndAddResponseListener(countDownLatch);
-        helper.server.getLwM2mRequestSender().send(helper.getClient(), TEST_REQUEST_TICKET + "1",
+        helper.server.getLwM2mRequestSender().send(helper.getCurrentRegistration(), TEST_REQUEST_TICKET + "1",
                 new ReadRequest(3, 0));
         if (!countDownLatch.await(2, TimeUnit.SECONDS)) {
             fail("response from client was not received within timeout");
@@ -129,7 +131,7 @@ public class QueueModeTest {
 
         createAndAddResponseListener(countDownLatch);
 
-        helper.server.getLwM2mRequestSender().send(helper.getClient(), TEST_REQUEST_TICKET + "1",
+        helper.server.getLwM2mRequestSender().send(helper.getCurrentRegistration(), TEST_REQUEST_TICKET + "1",
                 new ReadRequest(3, 0));
         // assert that queue has one request left in processing state still
         assertQueueHasMessageCount(1, 5000);
@@ -146,7 +148,7 @@ public class QueueModeTest {
         createAndAddResponseListener(acceptCountDownLatch);
 
         // send request but no response should be received
-        helper.server.getLwM2mRequestSender().send(helper.getClient(), TEST_REQUEST_TICKET + "1",
+        helper.server.getLwM2mRequestSender().send(helper.getCurrentRegistration(), TEST_REQUEST_TICKET + "1",
                 new ReadRequest(3, 0, 1));
 
         // assert that queue has one request left in processing state still
@@ -155,7 +157,7 @@ public class QueueModeTest {
         // as client has not yet sent any register-update or notify, sending
         // next request
         // request should only be queued and not sent
-        helper.server.getLwM2mRequestSender().send(helper.getClient(), TEST_REQUEST_TICKET + "2",
+        helper.server.getLwM2mRequestSender().send(helper.getCurrentRegistration(), TEST_REQUEST_TICKET + "2",
                 new ReadRequest(3, 0, 2));
         if (acceptCountDownLatch.await(3, TimeUnit.SECONDS)) {
             fail("response from client after first request timed out is unexpected");
@@ -163,7 +165,7 @@ public class QueueModeTest {
 
         // assert that queue has one additional new request
         assertEquals(2, ((InMemoryMessageStore) helper.server.getMessageStore())
-                .getQueueSize(helper.getClient().getEndpoint()));
+                .getQueueSize(helper.getCurrentRegistration().getEndpoint()));
     }
 
     @Test
@@ -192,7 +194,7 @@ public class QueueModeTest {
 
         // Send a read request. Will be sent immediately as it is the first
         // message in the queue.
-        helper.server.getLwM2mRequestSender().send(helper.getClient(), TEST_REQUEST_TICKET + "1",
+        helper.server.getLwM2mRequestSender().send(helper.getCurrentRegistration(), TEST_REQUEST_TICKET + "1",
                 new ReadRequest(3, 0, 1));
 
         // after first (not responded) request, coundDown should be zero.
@@ -214,7 +216,7 @@ public class QueueModeTest {
         }
 
         assertEquals(0, ((InMemoryMessageStore) helper.server.getMessageStore())
-                .getQueueSize(helper.getClient().getEndpoint()));
+                .getQueueSize(helper.getCurrentRegistration().getEndpoint()));
     }
 
     @Test
@@ -235,7 +237,7 @@ public class QueueModeTest {
                 if (response instanceof ObserveResponse) {
                     Observation observation = ((ObserveResponse) response).getObservation();
                     assertEquals("/3/0/15", observation.getPath().toString());
-                    assertEquals(helper.getClient().getRegistrationId(), observation.getRegistrationId());
+                    assertEquals(helper.getCurrentRegistration().getRegistrationId(), observation.getRegistrationId());
                 }
             }
 
@@ -248,7 +250,7 @@ public class QueueModeTest {
         // Send an Observe request. Will be sent immediately as it is the first
         // message in the queue. Response will bre processed by the
         // ResponseListener defined above.
-        helper.server.getLwM2mRequestSender().send(helper.getClient(), TEST_REQUEST_TICKET + "1",
+        helper.server.getLwM2mRequestSender().send(helper.getCurrentRegistration(), TEST_REQUEST_TICKET + "1",
                 new ObserveRequest(3, 0, 15));
         // Wait for read request timeout
         waitForInterval(TIMEOUT);
@@ -260,7 +262,7 @@ public class QueueModeTest {
         client.setOnGetCallback(doNothingOnGet);
         // add a read response listener.
         createAndAddResponseListener(acceptCountDownLatch);
-        helper.server.getLwM2mRequestSender().send(helper.getClient(), TEST_REQUEST_TICKET + "2",
+        helper.server.getLwM2mRequestSender().send(helper.getCurrentRegistration(), TEST_REQUEST_TICKET + "2",
                 new ReadRequest(3, 0, 15));
         // read request should be left in Queue still.
         assertQueueHasMessageCount(1, 5000);
@@ -268,7 +270,7 @@ public class QueueModeTest {
         // set client to respond to GET
         client.setOnGetCallback(respondOnGet);
         // write device timezone
-        helper.server.getLwM2mRequestSender().send(helper.getClient(), TEST_REQUEST_TICKET + "3",
+        helper.server.getLwM2mRequestSender().send(helper.getCurrentRegistration(), TEST_REQUEST_TICKET + "3",
                 new WriteRequest(3, 0, 15, "Europe/Berlin"));
 
         // wait for client update.
@@ -293,7 +295,7 @@ public class QueueModeTest {
                     LOG.trace("Received observe response for ticket {} from LWM2M client {}", requestTicket, response);
                     Observation observation = ((ObserveResponse) response).getObservation();
                     assertEquals("/3/0/15", observation.getPath().toString());
-                    assertEquals(helper.getClient().getRegistrationId(), observation.getRegistrationId());
+                    assertEquals(helper.getCurrentRegistration().getRegistrationId(), observation.getRegistrationId());
                 }
             }
 
@@ -307,14 +309,14 @@ public class QueueModeTest {
         client.setOnGetCallback(respondOnGet);
         // Send an Observe request. Will be sent immediately as it is the first
         // message in the queue.
-        helper.server.getLwM2mRequestSender().send(helper.getClient(), TEST_REQUEST_TICKET + "1",
+        helper.server.getLwM2mRequestSender().send(helper.getCurrentRegistration(), TEST_REQUEST_TICKET + "1",
                 new ObserveRequest(3, 0, 15));
         waitForInterval(TIMEOUT);
         // remove observe response listener
         helper.server.getLwM2mRequestSender().removeResponseListener(responseListener);
 
         // write device timezone.
-        helper.server.getLwM2mRequestSender().send(helper.getClient(), TEST_REQUEST_TICKET + "2",
+        helper.server.getLwM2mRequestSender().send(helper.getCurrentRegistration(), TEST_REQUEST_TICKET + "2",
                 new WriteRequest(3, 0, 15, "Europe/Berlin"));
 
         // Read request should be sent immediately.
@@ -337,7 +339,7 @@ public class QueueModeTest {
             }
         };
         helper.server.getLwM2mRequestSender().addResponseListener(responseListener);
-        helper.server.getLwM2mRequestSender().send(helper.getClient(), TEST_REQUEST_TICKET + "3",
+        helper.server.getLwM2mRequestSender().send(helper.getCurrentRegistration(), TEST_REQUEST_TICKET + "3",
                 new ReadRequest(3, 0, 1));
 
         waitForInterval(TIMEOUT);
@@ -371,7 +373,7 @@ public class QueueModeTest {
                     LOG.trace("Received observe response for ticket {} from LWM2M client {}", requestTicket, response);
                     Observation observation = ((ObserveResponse) response).getObservation();
                     assertEquals("/3/0/15", observation.getPath().toString());
-                    assertEquals(helper.getClient().getRegistrationId(), observation.getRegistrationId());
+                    assertEquals(helper.getCurrentRegistration().getRegistrationId(), observation.getRegistrationId());
                 }
             }
 
@@ -383,13 +385,13 @@ public class QueueModeTest {
         helper.server.getLwM2mRequestSender().addResponseListener(responseListener);
         // Send an Observe request. Will be sent immediately as it is the first
         // message in the queue.
-        helper.server.getLwM2mRequestSender().send(helper.getClient(), TEST_REQUEST_TICKET + "1",
+        helper.server.getLwM2mRequestSender().send(helper.getCurrentRegistration(), TEST_REQUEST_TICKET + "1",
                 new ObserveRequest(3, 0, 15));
         waitForInterval(TIMEOUT);
 
         // Now set the client NOT to respond to GET and send a request
         client.setOnGetCallback(doNothingOnGet);
-        helper.server.getLwM2mRequestSender().send(helper.getClient(), TEST_REQUEST_TICKET + "2",
+        helper.server.getLwM2mRequestSender().send(helper.getCurrentRegistration(), TEST_REQUEST_TICKET + "2",
                 new ReadRequest(3, 0, 1));
 
         waitForInterval(TIMEOUT);
@@ -409,10 +411,10 @@ public class QueueModeTest {
         });
 
         // write device timezone
-        helper.server.getLwM2mRequestSender().send(helper.getClient(), TEST_REQUEST_TICKET + "3",
+        helper.server.getLwM2mRequestSender().send(helper.getCurrentRegistration(), TEST_REQUEST_TICKET + "3",
                 new WriteRequest(3, 0, 15, "Europe/Amsterdam"));
         // write device timezone
-        helper.server.getLwM2mRequestSender().send(helper.getClient(), TEST_REQUEST_TICKET + "4",
+        helper.server.getLwM2mRequestSender().send(helper.getCurrentRegistration(), TEST_REQUEST_TICKET + "4",
                 new WriteRequest(3, 0, 15, "Europe/Paris"));
 
         assertQueueIsEmpty(3000);
@@ -441,11 +443,11 @@ public class QueueModeTest {
         createAndAddResponseListener(acceptCountDownLatch);
         // Send a read request. Will be sent immediately as it is the first
         // message in the queue.
-        helper.server.getLwM2mRequestSender().send(helper.getClient(), TEST_REQUEST_TICKET + "1",
+        helper.server.getLwM2mRequestSender().send(helper.getCurrentRegistration(), TEST_REQUEST_TICKET + "1",
                 new ReadRequest(3, 0, 1));
-        helper.server.getLwM2mRequestSender().send(helper.getClient(), TEST_REQUEST_TICKET + "2",
+        helper.server.getLwM2mRequestSender().send(helper.getCurrentRegistration(), TEST_REQUEST_TICKET + "2",
                 new ReadRequest(3, 0, 15));
-        helper.server.getLwM2mRequestSender().send(helper.getClient(), TEST_REQUEST_TICKET + "3",
+        helper.server.getLwM2mRequestSender().send(helper.getCurrentRegistration(), TEST_REQUEST_TICKET + "3",
                 new ReadRequest(3, 0, 2));
 
         waitForInterval(TIMEOUT);
@@ -468,11 +470,11 @@ public class QueueModeTest {
         createAndAddResponseListener(acceptCountDownLatch);
         // Send a read request. Will be sent immediately as it is the first
         // message in the queue.
-        helper.server.getLwM2mRequestSender().send(helper.getClient(), TEST_REQUEST_TICKET + "1",
+        helper.server.getLwM2mRequestSender().send(helper.getCurrentRegistration(), TEST_REQUEST_TICKET + "1",
                 new ReadRequest(3, 0, 1));
-        helper.server.getLwM2mRequestSender().send(helper.getClient(), TEST_REQUEST_TICKET + "2",
+        helper.server.getLwM2mRequestSender().send(helper.getCurrentRegistration(), TEST_REQUEST_TICKET + "2",
                 new ReadRequest(3, 0, 15));
-        helper.server.getLwM2mRequestSender().send(helper.getClient(), TEST_REQUEST_TICKET + "3",
+        helper.server.getLwM2mRequestSender().send(helper.getCurrentRegistration(), TEST_REQUEST_TICKET + "3",
                 new ReadRequest(3, 0, 2));
 
         assertQueueHasMessageCount(3, 5000);
@@ -509,11 +511,11 @@ public class QueueModeTest {
             }
         });
 
-        helper.server.getLwM2mRequestSender().send(helper.getClient(), TEST_REQUEST_TICKET + "1",
+        helper.server.getLwM2mRequestSender().send(helper.getCurrentRegistration(), TEST_REQUEST_TICKET + "1",
                 new ReadRequest(3, 0, 1));
-        helper.server.getLwM2mRequestSender().send(helper.getClient(), TEST_REQUEST_TICKET + "2",
+        helper.server.getLwM2mRequestSender().send(helper.getCurrentRegistration(), TEST_REQUEST_TICKET + "2",
                 new ReadRequest(3, 0, 15));
-        helper.server.getLwM2mRequestSender().send(helper.getClient(), TEST_REQUEST_TICKET + "3",
+        helper.server.getLwM2mRequestSender().send(helper.getCurrentRegistration(), TEST_REQUEST_TICKET + "3",
                 new ReadRequest(3, 0, 2));
         // Send de-register
         helper.client.stop(DEREGISTER);
@@ -526,7 +528,7 @@ public class QueueModeTest {
     @Test
     public void cancel_pending_throws_exception_for_first_message_and_doesnot_send_others() throws Exception {
         final CountDownLatch exceptionCountDownLatch = new CountDownLatch(1);
-        final CountDownLatch responseCountDownLatch = new CountDownLatch(1);
+        final CountDownLatch responseCountDownLatch = new CountDownLatch(2);
         final CountDownLatch unexpectedResponseCountDownLatch = new CountDownLatch(2);
 
         QueuedModeLeshanClient client = (QueuedModeLeshanClient) helper.client;
@@ -549,12 +551,12 @@ public class QueueModeTest {
             }
         });
 
-        helper.server.getLwM2mRequestSender().send(helper.getClient(), TEST_REQUEST_TICKET + "1",
+        helper.server.getLwM2mRequestSender().send(helper.getCurrentRegistration(), TEST_REQUEST_TICKET + "1",
                 new ReadRequest(3, 0, 1));
-        helper.server.getLwM2mRequestSender().send(helper.getClient(), TEST_REQUEST_TICKET + "2",
+        helper.server.getLwM2mRequestSender().send(helper.getCurrentRegistration(), TEST_REQUEST_TICKET + "2",
                 new ReadRequest(3, 0, 15));
         // Instead of LWM2M client de-register, cancel pending messages on LWM2M server.
-        helper.server.getLwM2mRequestSender().cancelPendingRequests(helper.getClient());
+        helper.server.getLwM2mRequestSender().cancelPendingRequests(helper.getCurrentRegistration());
         responseCountDownLatch.countDown(); // client will start responding from this point.
         assertQueueIsEmpty(3000);
         assertTrue("Did not expect any responses", unexpectedResponseCountDownLatch.getCount() == 2);
@@ -564,7 +566,7 @@ public class QueueModeTest {
 
     @Test
     public void sending_message_for_unknown_client_gives_error_response() throws InterruptedException {
-        Client destination = helper.getClient();
+        Client destination = helper.getCurrentRegistration();
         // stop the lwm2m client created by default
         helper.client.stop(DEREGISTER);
 
@@ -621,7 +623,7 @@ public class QueueModeTest {
             Thread.sleep(interval);
             duration += interval;
             InMemoryMessageStore messageStore = (InMemoryMessageStore) helper.server.getMessageStore();
-            queuedRequestCount = messageStore.getQueueSize(helper.getClient().getEndpoint());
+            queuedRequestCount = messageStore.getQueueSize(helper.getCurrentRegistration().getEndpoint());
         } while (queuedRequestCount < count && duration <= timeout);
         assertTrue(
                 "Expected to have at least " + count + " queued request in queue but have [" + queuedRequestCount + "]",
@@ -636,7 +638,7 @@ public class QueueModeTest {
         do {
             Thread.sleep(interval);
             duration += interval;
-            empty = messageStore.isEmpty(QueueModeIntegrationTestHelper.ENDPOINT_IDENTIFIER);
+            empty = messageStore.isEmpty(helper.getCurrentEndpoint());
         } while (!empty && duration <= timeout);
         assertTrue("Expected an empty queue but has some messages", empty);
     }
diff --git a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/ReadTest.java b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/ReadTest.java
index 988c1265..4616b56c 100644
--- a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/ReadTest.java
+++ b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/ReadTest.java
@@ -17,11 +17,8 @@
 
 package org.eclipse.leshan.integration.tests;
 
-import static org.eclipse.leshan.ResponseCode.CONTENT;
-import static org.eclipse.leshan.ResponseCode.METHOD_NOT_ALLOWED;
-import static org.eclipse.leshan.ResponseCode.NOT_FOUND;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.eclipse.leshan.ResponseCode.*;
+import static org.junit.Assert.*;
 
 import org.eclipse.leshan.core.node.LwM2mObject;
 import org.eclipse.leshan.core.node.LwM2mObjectInstance;
@@ -38,6 +35,7 @@ public class ReadTest {
 
     @Before
     public void start() {
+        helper.initialize();
         helper.createServer();
         helper.server.start();
         helper.createClient();
@@ -49,12 +47,13 @@ public class ReadTest {
     public void stop() {
         helper.client.stop(false);
         helper.server.stop();
+        helper.dispose();
     }
 
     @Test
     public void can_read_empty_object() throws InterruptedException {
         // read ACL object
-        ReadResponse response = helper.server.send(helper.getClient(), new ReadRequest(2));
+        ReadResponse response = helper.server.send(helper.getCurrentRegistration(), new ReadRequest(2));
 
         // verify result
         assertEquals(CONTENT, response.getCode());
@@ -67,7 +66,7 @@ public class ReadTest {
     @Test
     public void can_read_object() throws InterruptedException {
         // read device object
-        ReadResponse response = helper.server.send(helper.getClient(), new ReadRequest(3));
+        ReadResponse response = helper.server.send(helper.getCurrentRegistration(), new ReadRequest(3));
 
         // verify result
         assertEquals(CONTENT, response.getCode());
@@ -82,7 +81,7 @@ public class ReadTest {
     @Test
     public void can_read_object_instance() throws InterruptedException {
         // read device single instance
-        ReadResponse response = helper.server.send(helper.getClient(), new ReadRequest(3, 0));
+        ReadResponse response = helper.server.send(helper.getCurrentRegistration(), new ReadRequest(3, 0));
 
         // verify result
         assertEquals(CONTENT, response.getCode());
@@ -94,7 +93,7 @@ public class ReadTest {
     @Test
     public void can_read_resource() throws InterruptedException {
         // read device model number
-        ReadResponse response = helper.server.send(helper.getClient(), new ReadRequest(3, 0, 1));
+        ReadResponse response = helper.server.send(helper.getCurrentRegistration(), new ReadRequest(3, 0, 1));
 
         // verify result
         assertEquals(CONTENT, response.getCode());
@@ -107,7 +106,7 @@ public class ReadTest {
     @Test
     public void cannot_read_non_readable_resource() throws InterruptedException {
         // read device reboot resource
-        ReadResponse response = helper.server.send(helper.getClient(), new ReadRequest(3, 0, 4));
+        ReadResponse response = helper.server.send(helper.getCurrentRegistration(), new ReadRequest(3, 0, 4));
 
         // verify result
         assertEquals(METHOD_NOT_ALLOWED, response.getCode());
@@ -116,7 +115,7 @@ public class ReadTest {
     @Test
     public void cannot_read_non_existent_object() throws InterruptedException {
         // read object "50"
-        ReadResponse response = helper.server.send(helper.getClient(), new ReadRequest(50));
+        ReadResponse response = helper.server.send(helper.getCurrentRegistration(), new ReadRequest(50));
 
         // verify result
         assertEquals(NOT_FOUND, response.getCode());
@@ -125,7 +124,7 @@ public class ReadTest {
     @Test
     public void cannot_read_non_existent_instance() throws InterruptedException {
         // read 2nd Device resource
-        ReadResponse response = helper.server.send(helper.getClient(), new ReadRequest(3, 1));
+        ReadResponse response = helper.server.send(helper.getCurrentRegistration(), new ReadRequest(3, 1));
 
         // verify result
         assertEquals(NOT_FOUND, response.getCode());
@@ -134,7 +133,7 @@ public class ReadTest {
     @Test
     public void cannot_read_non_existent_resource() throws InterruptedException {
         // read device 50 resource
-        ReadResponse response = helper.server.send(helper.getClient(), new ReadRequest(3, 0, 50));
+        ReadResponse response = helper.server.send(helper.getCurrentRegistration(), new ReadRequest(3, 0, 50));
 
         // verify result
         assertEquals(NOT_FOUND, response.getCode());
@@ -143,7 +142,7 @@ public class ReadTest {
     @Test
     public void cannot_read_security_resource() throws InterruptedException {
         // read device 50 resource
-        ReadResponse response = helper.server.send(helper.getClient(), new ReadRequest(0, 0, 0));
+        ReadResponse response = helper.server.send(helper.getCurrentRegistration(), new ReadRequest(0, 0, 0));
 
         // verify result
         assertEquals(NOT_FOUND, response.getCode());
diff --git a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/RedisIntegrationTestHelper.java b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/RedisIntegrationTestHelper.java
new file mode 100644
index 00000000..056d6fbb
--- /dev/null
+++ b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/RedisIntegrationTestHelper.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Sierra Wireless and others.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ * 
+ * The Eclipse Public License is available at
+ *    http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ *    http://www.eclipse.org/org/documents/edl-v10.html.
+ * 
+ * Contributors:
+ *     Sierra Wireless - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.leshan.integration.tests;
+
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+
+import org.eclipse.leshan.core.node.codec.DefaultLwM2mNodeDecoder;
+import org.eclipse.leshan.server.californium.LeshanServerBuilder;
+import org.eclipse.leshan.server.californium.impl.CaliforniumObservationRegistryImpl;
+import org.eclipse.leshan.server.client.Client;
+import org.eclipse.leshan.server.client.ClientRegistry;
+import org.eclipse.leshan.server.client.ClientRegistryListener;
+import org.eclipse.leshan.server.client.ClientUpdate;
+import org.eclipse.leshan.server.demo.cluster.RedisClientRegistry;
+import org.eclipse.leshan.server.demo.cluster.RedisObservationStore;
+import org.eclipse.leshan.server.impl.SecurityRegistryImpl;
+import org.eclipse.leshan.server.model.StaticModelProvider;
+
+import redis.clients.jedis.Jedis;
+import redis.clients.jedis.JedisPool;
+import redis.clients.util.Pool;
+
+public class RedisIntegrationTestHelper extends IntegrationTestHelper {
+    @Override
+    public void createServer() {
+        LeshanServerBuilder builder = new LeshanServerBuilder();
+        StaticModelProvider modelProvider = new StaticModelProvider(createObjectModels());
+        builder.setObjectModelProvider(modelProvider);
+        DefaultLwM2mNodeDecoder decoder = new DefaultLwM2mNodeDecoder();
+        builder.setDecoder(decoder);
+        builder.setLocalAddress(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
+        builder.setLocalSecureAddress(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
+        builder.setSecurityRegistry(new SecurityRegistryImpl() {
+            // TODO we should separate SecurityRegistryImpl in 2 registries :
+            // InMemorySecurityRegistry and PersistentSecurityRegistry
+
+            @Override
+            protected void loadFromFile() {
+                // do not load From File
+            }
+
+            @Override
+            protected void saveToFile() {
+                // do not save to file
+            }
+        });
+
+        // Create redis store
+        Pool<Jedis> jedis = new JedisPool(System.getenv("REDIS_URI"));
+        ClientRegistry clientRegistry = new RedisClientRegistry(jedis);
+        builder.setClientRegistry(clientRegistry);
+        builder.setObservationRegistry(
+                new CaliforniumObservationRegistryImpl(new RedisObservationStore(jedis), clientRegistry, modelProvider,
+                        decoder));
+
+        // Build server !
+        server = builder.build();
+        // monitor client registration
+        resetLatch();
+        server.getClientRegistry().addListener(new ClientRegistryListener() {
+            @Override
+            public void updated(ClientUpdate update, Client clientUpdated) {
+                if (clientUpdated.getEndpoint().equals(getCurrentEndpoint())) {
+                    updateLatch.countDown();
+                }
+            }
+
+            @Override
+            public void unregistered(Client client) {
+                if (client.getEndpoint().equals(getCurrentEndpoint())) {
+                    deregisterLatch.countDown();
+                }
+            }
+
+            @Override
+            public void registered(Client client) {
+                if (client.getEndpoint().equals(getCurrentEndpoint())) {
+                    last_registration = client;
+                    registerLatch.countDown();
+                }
+            }
+        });
+    }
+}
diff --git a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/RedisObserveTest.java b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/RedisObserveTest.java
new file mode 100644
index 00000000..ef48595d
--- /dev/null
+++ b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/RedisObserveTest.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Sierra Wireless and others.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ * 
+ * The Eclipse Public License is available at
+ *    http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ *    http://www.eclipse.org/org/documents/edl-v10.html.
+ * 
+ * Contributors:
+ *     Sierra Wireless - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.leshan.integration.tests;
+
+public class RedisObserveTest extends ObserveTest {
+
+    public RedisObserveTest() {
+        helper = new RedisIntegrationTestHelper();
+    }
+}
diff --git a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/RedisRegistrationTest.java b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/RedisRegistrationTest.java
new file mode 100644
index 00000000..f8c279ec
--- /dev/null
+++ b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/RedisRegistrationTest.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Sierra Wireless and others.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ * 
+ * The Eclipse Public License is available at
+ *    http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ *    http://www.eclipse.org/org/documents/edl-v10.html.
+ * 
+ * Contributors:
+ *     Sierra Wireless - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.leshan.integration.tests;
+
+public class RedisRegistrationTest extends RegistrationTest {
+
+    public RedisRegistrationTest() {
+        helper = new RedisIntegrationTestHelper();
+    }
+}
diff --git a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/RedisSecureIntegrationTestHelper.java b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/RedisSecureIntegrationTestHelper.java
new file mode 100644
index 00000000..006ae965
--- /dev/null
+++ b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/RedisSecureIntegrationTestHelper.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Sierra Wireless and others.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ * 
+ * The Eclipse Public License is available at
+ *    http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ *    http://www.eclipse.org/org/documents/edl-v10.html.
+ * 
+ * Contributors:
+ *     Sierra Wireless - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.leshan.integration.tests;
+
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.security.cert.Certificate;
+
+import org.eclipse.leshan.core.node.codec.DefaultLwM2mNodeDecoder;
+import org.eclipse.leshan.server.californium.LeshanServerBuilder;
+import org.eclipse.leshan.server.californium.impl.CaliforniumObservationRegistryImpl;
+import org.eclipse.leshan.server.client.Client;
+import org.eclipse.leshan.server.client.ClientRegistry;
+import org.eclipse.leshan.server.client.ClientRegistryListener;
+import org.eclipse.leshan.server.client.ClientUpdate;
+import org.eclipse.leshan.server.demo.cluster.RedisClientRegistry;
+import org.eclipse.leshan.server.demo.cluster.RedisObservationStore;
+import org.eclipse.leshan.server.demo.cluster.RedisSecurityRegistry;
+import org.eclipse.leshan.server.model.StaticModelProvider;
+
+import redis.clients.jedis.Jedis;
+import redis.clients.jedis.JedisPool;
+import redis.clients.util.Pool;
+
+public class RedisSecureIntegrationTestHelper extends SecureIntegrationTestHelper {
+    @Override
+    public void createServer() {
+        LeshanServerBuilder builder = new LeshanServerBuilder();
+        StaticModelProvider modelProvider = new StaticModelProvider(createObjectModels());
+        builder.setObjectModelProvider(modelProvider);
+        DefaultLwM2mNodeDecoder decoder = new DefaultLwM2mNodeDecoder();
+        builder.setDecoder(decoder);
+        builder.setLocalAddress(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
+        builder.setLocalSecureAddress(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
+
+        // Create redis store
+        Pool<Jedis> jedis = new JedisPool(System.getenv("REDIS_URI"));
+        ClientRegistry clientRegistry = new RedisClientRegistry(jedis);
+        builder.setClientRegistry(clientRegistry);
+        builder.setObservationRegistry(new CaliforniumObservationRegistryImpl(new RedisObservationStore(jedis),
+                clientRegistry, modelProvider, decoder));
+        builder.setSecurityRegistry(new RedisSecurityRegistry(jedis, null, null));
+
+        // Build server !
+        server = builder.build();
+        // monitor client registration
+        resetLatch();
+        server.getClientRegistry().addListener(new ClientRegistryListener() {
+            @Override
+            public void updated(ClientUpdate update, Client clientUpdated) {
+                if (clientUpdated.getEndpoint().equals(getCurrentEndpoint())) {
+                    updateLatch.countDown();
+                }
+            }
+
+            @Override
+            public void unregistered(Client client) {
+                if (client.getEndpoint().equals(getCurrentEndpoint())) {
+                    deregisterLatch.countDown();
+                }
+            }
+
+            @Override
+            public void registered(Client client) {
+                if (client.getEndpoint().equals(getCurrentEndpoint())) {
+                    last_registration = client;
+                    registerLatch.countDown();
+                }
+            }
+        });
+    }
+
+    @Override
+    public void createServerWithRPK() {
+        throw new UnsupportedOperationException("Not implemeneted");
+    }
+
+    @Override
+    public void createServerWithX509Cert(Certificate[] trustedCertificates) {
+        throw new UnsupportedOperationException("Not implemeneted");
+    }
+
+}
diff --git a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/RedisSecurityTest.java b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/RedisSecurityTest.java
new file mode 100644
index 00000000..9f2b78c2
--- /dev/null
+++ b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/RedisSecurityTest.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Sierra Wireless and others.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ * 
+ * The Eclipse Public License is available at
+ *    http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ *    http://www.eclipse.org/org/documents/edl-v10.html.
+ * 
+ * Contributors:
+ *     Sierra Wireless - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.leshan.integration.tests;
+
+public class RedisSecurityTest extends SecurityTest {
+    public RedisSecurityTest() {
+        helper = new RedisSecureIntegrationTestHelper();
+    }
+}
diff --git a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/RegistrationTest.java b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/RegistrationTest.java
index 22ac49a0..aea55b70 100644
--- a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/RegistrationTest.java
+++ b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/RegistrationTest.java
@@ -16,14 +16,8 @@
 
 package org.eclipse.leshan.integration.tests;
 
-import static org.eclipse.leshan.integration.tests.IntegrationTestHelper.ENDPOINT_IDENTIFIER;
 import static org.eclipse.leshan.integration.tests.IntegrationTestHelper.LIFETIME;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
 
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
@@ -39,10 +33,11 @@ import org.eclipse.leshan.client.californium.impl.CaliforniumLwM2mClientRequestS
 import org.eclipse.leshan.client.resource.LwM2mInstanceEnabler;
 import org.eclipse.leshan.client.resource.LwM2mObjectEnabler;
 import org.eclipse.leshan.client.resource.ObjectEnabler;
+import org.eclipse.leshan.core.request.DeregisterRequest;
 import org.eclipse.leshan.core.request.ReadRequest;
 import org.eclipse.leshan.core.request.RegisterRequest;
 import org.eclipse.leshan.core.response.ReadResponse;
-import org.eclipse.leshan.server.client.Client;
+import org.eclipse.leshan.core.response.RegisterResponse;
 import org.eclipse.leshan.server.security.NonUniqueSecurityInfoException;
 import org.junit.After;
 import org.junit.Before;
@@ -50,59 +45,60 @@ import org.junit.Test;
 
 public class RegistrationTest {
 
-    private final IntegrationTestHelper helper = new IntegrationTestHelper();
+    protected IntegrationTestHelper helper = new IntegrationTestHelper();
 
     @Before
     public void start() {
+        helper.initialize();
         helper.createServer();
         helper.server.start();
         helper.createClient();
-
     }
 
     @After
-    public void stop() {
+    public void stop() throws InterruptedException {
+        helper.client.stop(true);
         helper.server.stop();
+        helper.dispose();
     }
 
     @Test
     public void register_update_deregister() {
-        // Check registration
-        assertTrue(helper.server.getClientRegistry().allClients().isEmpty());
+        // Check client is not registered
+        helper.assertClientNotRegisterered();
 
+        // Start it and wait for registration
         helper.client.start();
         helper.waitForRegistration(1);
 
-        assertEquals(1, helper.server.getClientRegistry().allClients().size());
-        Client client = helper.server.getClientRegistry().get(ENDPOINT_IDENTIFIER);
-        assertNotNull(client);
-        // TODO </0/0> should not be part of the object links
+        // Check client is well registered
+        helper.assertClientRegisterered();
         assertArrayEquals(LinkObject.parse("</>;rt=\"oma.lwm2m\",</1/0>,</2>,</3/0>,</2000/0>".getBytes()),
-                client.getObjectLinks());
+                helper.getCurrentRegistration().getObjectLinks());
 
         // Check for update
         helper.waitForUpdate(LIFETIME);
-        assertEquals(1, helper.server.getClientRegistry().allClients().size());
+        helper.assertClientRegisterered();
 
         // Check deregistration
         helper.client.stop(true);
         helper.waitForDeregistration(1);
-        assertTrue(helper.server.getClientRegistry().allClients().isEmpty());
+        helper.assertClientNotRegisterered();
     }
 
     @Test
     public void deregister_cancel_multiple_pending_request() throws InterruptedException {
-        // Check registration
-        assertTrue(helper.server.getClientRegistry().allClients().isEmpty());
+        // Check client is not registered
+        helper.assertClientNotRegisterered();
 
+        // Start it and wait for registration
         helper.client.start();
         helper.waitForRegistration(1);
 
-        assertEquals(1, helper.server.getClientRegistry().allClients().size());
-        Client client = helper.server.getClientRegistry().get(ENDPOINT_IDENTIFIER);
-        assertNotNull(client);
+        // Check client is well registered
+        helper.assertClientRegisterered();
         assertArrayEquals(LinkObject.parse("</>;rt=\"oma.lwm2m\",</1/0>,</2>,</3/0>,</2000/0>".getBytes()),
-                client.getObjectLinks());
+                helper.getCurrentRegistration().getObjectLinks());
 
         // Stop client with out de-registration
         helper.client.stop(false);
@@ -112,7 +108,7 @@ public class RegistrationTest {
 
         for (int index = 0; index < 4; ++index) {
             Callback<ReadResponse> callback = new Callback<ReadResponse>();
-            helper.server.send(client, new ReadRequest(3, 0, 1), callback, callback);
+            helper.server.send(helper.getCurrentRegistration(), new ReadRequest(3, 0, 1), callback, callback);
             callbacks.add(callback);
         }
 
@@ -133,58 +129,58 @@ public class RegistrationTest {
 
     @Test
     public void register_update_deregister_reregister() throws NonUniqueSecurityInfoException, InterruptedException {
-        // Check registration
-        assertTrue(helper.server.getClientRegistry().allClients().isEmpty());
+        // Check client is not registered
+        helper.assertClientNotRegisterered();
 
+        // Start it and wait for registration
         helper.client.start();
         helper.waitForRegistration(1);
 
-        assertEquals(1, helper.server.getClientRegistry().allClients().size());
-        assertNotNull(helper.server.getClientRegistry().get(ENDPOINT_IDENTIFIER));
+        // Check client is well registered
+        helper.assertClientRegisterered();
 
         // Check for update
         helper.waitForUpdate(LIFETIME);
-        assertEquals(1, helper.server.getClientRegistry().allClients().size());
+        helper.assertClientRegisterered();
 
         // Check de-registration
         helper.client.stop(true);
         helper.waitForDeregistration(1);
-        assertTrue(helper.server.getClientRegistry().allClients().isEmpty());
+        helper.assertClientNotRegisterered();
 
         // Check new registration
         helper.resetLatch();
         helper.client.start();
         helper.waitForRegistration(1);
-        assertEquals(1, helper.server.getClientRegistry().allClients().size());
-        assertNotNull(helper.server.getClientRegistry().get(ENDPOINT_IDENTIFIER));
+        helper.assertClientRegisterered();
     }
 
     @Test
     public void register_update_reregister() throws NonUniqueSecurityInfoException, InterruptedException {
-        // Check registration
-        assertTrue(helper.server.getClientRegistry().allClients().isEmpty());
+        // Check client is not registered
+        helper.assertClientNotRegisterered();
 
+        // Start it and wait for registration
         helper.client.start();
         helper.waitForRegistration(1);
 
-        assertEquals(1, helper.server.getClientRegistry().allClients().size());
-        assertNotNull(helper.server.getClientRegistry().get(ENDPOINT_IDENTIFIER));
+        // Check client is well registered
+        helper.assertClientRegisterered();
 
         // Check for update
         helper.waitForUpdate(LIFETIME);
-        assertEquals(1, helper.server.getClientRegistry().allClients().size());
+        helper.assertClientRegisterered();
 
         // check stop do not de-register
         helper.client.stop(false);
         helper.waitForDeregistration(1);
-        assertEquals(1, helper.server.getClientRegistry().allClients().size());
+        helper.assertClientRegisterered();
 
         // check new registration
         helper.resetLatch();
         helper.client.start();
         helper.waitForRegistration(1);
-        assertEquals(1, helper.server.getClientRegistry().allClients().size());
-        assertNotNull(helper.server.getClientRegistry().get(ENDPOINT_IDENTIFIER));
+        helper.assertClientRegisterered();
     }
 
     // TODO not really a registration test
@@ -202,7 +198,7 @@ public class RegistrationTest {
     @Test
     public void register_with_additional_attributes() throws InterruptedException {
         // Check registration
-        assertTrue(helper.server.getClientRegistry().allClients().isEmpty());
+        helper.assertClientNotRegisterered();
 
         // HACK to be able to send a Registration request with additional attributes
         LeshanClient lclient = (LeshanClient) helper.client;
@@ -217,23 +213,24 @@ public class RegistrationTest {
         additionalAttributes.put("key1", "value1");
         additionalAttributes.put("imei", "2136872368");
         LinkObject[] linkObjects = LinkObject.parse("</>;rt=\"oma.lwm2m\",</0/0>,</1/0>,</2>,</3/0>".getBytes());
-        RegisterRequest registerRequest = new RegisterRequest(ENDPOINT_IDENTIFIER, null, null, null, null, linkObjects,
+        RegisterRequest registerRequest = new RegisterRequest(helper.getCurrentEndpoint(), null, null,
+                null,
+                null, linkObjects,
                 additionalAttributes);
 
         // Send request
-        sender.send(helper.server.getNonSecureAddress(), false, registerRequest, 5000l);
+        RegisterResponse resp = sender.send(helper.server.getNonSecureAddress(), false, registerRequest, 5000l);
         helper.waitForRegistration(1);
 
         // Check we are registered with the expected attributes
-        assertEquals(1, helper.server.getClientRegistry().allClients().size());
-        Client client = helper.server.getClientRegistry().get(ENDPOINT_IDENTIFIER);
-        assertNotNull(client);
+        helper.assertClientRegisterered();
         assertNotNull(helper.last_registration);
         assertEquals(additionalAttributes, helper.last_registration.getAdditionalRegistrationAttributes());
         // TODO </0/0> should not be part of the object links
         assertArrayEquals(LinkObject.parse("</>;rt=\"oma.lwm2m\",</0/0>,</1/0>,</2>,</3/0>".getBytes()),
-                client.getObjectLinks());
+                helper.getCurrentRegistration().getObjectLinks());
 
+        sender.send(helper.server.getNonSecureAddress(), false, new DeregisterRequest(resp.getRegistrationID()), 5000l);
         lclient.getCoapServer().stop();
     }
 }
diff --git a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/SecureIntegrationTestHelper.java b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/SecureIntegrationTestHelper.java
index 05084ef7..12325824 100644
--- a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/SecureIntegrationTestHelper.java
+++ b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/SecureIntegrationTestHelper.java
@@ -57,8 +57,12 @@ import org.eclipse.leshan.util.Hex;
 
 public class SecureIntegrationTestHelper extends IntegrationTestHelper {
 
-    public final String pskIdentity = "Client_identity";
-    public final byte[] pskKey = Hex.decodeHex("73656372657450534b".toCharArray());
+    public static final String GOOD_PSK_ID = "Good_Client_identity";
+    public static final byte[] GOOD_PSK_KEY = Hex.decodeHex("73656372657450534b".toCharArray());
+    public static final String BAD_PSK_ID = "Bad_Client_identity";
+    public static final byte[] BAD_PSK_KEY = Hex.decodeHex("010101010101010101".toCharArray());
+    public static final String BAD_ENDPOINT = "bad_endpoint";
+
     public final PublicKey clientPublicKey;
     public final PrivateKey clientPrivateKey;
     public final PublicKey serverPublicKey;
@@ -76,12 +80,12 @@ public class SecureIntegrationTestHelper extends IntegrationTestHelper {
         // create client credentials
         try {
             // Get point values
-            byte[] publicX = Hex.decodeHex("89c048261979208666f2bfb188be1968fc9021c416ce12828c06f4e314c167b5"
-                    .toCharArray());
-            byte[] publicY = Hex.decodeHex("cbf1eb7587f08e01688d9ada4be859137ca49f79394bad9179326b3090967b68"
-                    .toCharArray());
-            byte[] privateS = Hex.decodeHex("e67b68d2aaeb6550f19d98cade3ad62b39532e02e6b422e1f7ea189dabaea5d2"
-                    .toCharArray());
+            byte[] publicX = Hex
+                    .decodeHex("89c048261979208666f2bfb188be1968fc9021c416ce12828c06f4e314c167b5".toCharArray());
+            byte[] publicY = Hex
+                    .decodeHex("cbf1eb7587f08e01688d9ada4be859137ca49f79394bad9179326b3090967b68".toCharArray());
+            byte[] privateS = Hex
+                    .decodeHex("e67b68d2aaeb6550f19d98cade3ad62b39532e02e6b422e1f7ea189dabaea5d2".toCharArray());
 
             // Get Elliptic Curve Parameter spec for secp256r1
             AlgorithmParameters algoParameters = AlgorithmParameters.getInstance("EC");
@@ -116,12 +120,12 @@ public class SecureIntegrationTestHelper extends IntegrationTestHelper {
         // create server credentials
         try {
             // Get point values
-            byte[] publicX = Hex.decodeHex("fcc28728c123b155be410fc1c0651da374fc6ebe7f96606e90d927d188894a73"
-                    .toCharArray());
-            byte[] publicY = Hex.decodeHex("d2ffaa73957d76984633fc1cc54d0b763ca0559a9dff9706e9f4557dacc3f52a"
-                    .toCharArray());
-            byte[] privateS = Hex.decodeHex("1dae121ba406802ef07c193c1ee4df91115aabd79c1ed7f4c0ef7ef6a5449400"
-                    .toCharArray());
+            byte[] publicX = Hex
+                    .decodeHex("fcc28728c123b155be410fc1c0651da374fc6ebe7f96606e90d927d188894a73".toCharArray());
+            byte[] publicY = Hex
+                    .decodeHex("d2ffaa73957d76984633fc1cc54d0b763ca0559a9dff9706e9f4557dacc3f52a".toCharArray());
+            byte[] privateS = Hex
+                    .decodeHex("1dae121ba406802ef07c193c1ee4df91115aabd79c1ed7f4c0ef7ef6a5449400".toCharArray());
 
             // Get Elliptic Curve Parameter spec for secp256r1
             AlgorithmParameters algoParameters = AlgorithmParameters.getInstance("EC");
@@ -156,17 +160,18 @@ public class SecureIntegrationTestHelper extends IntegrationTestHelper {
 
     public void createPSKClient() {
         ObjectsInitializer initializer = new ObjectsInitializer();
-        initializer.setInstancesForObject(
-                LwM2mId.SECURITY,
-                Security.psk("coaps://" + server.getSecureAddress().getHostString() + ":"
-                        + server.getSecureAddress().getPort(), 12345, pskIdentity.getBytes(Charsets.UTF_8), pskKey));
+        initializer.setInstancesForObject(LwM2mId.SECURITY,
+                Security.psk(
+                        "coaps://" + server.getSecureAddress().getHostString() + ":"
+                                + server.getSecureAddress().getPort(),
+                        12345, GOOD_PSK_ID.getBytes(Charsets.UTF_8), GOOD_PSK_KEY));
         initializer.setInstancesForObject(LwM2mId.SERVER, new Server(12345, LIFETIME, BindingMode.U, false));
         initializer.setInstancesForObject(LwM2mId.DEVICE, new Device("Eclipse Leshan", MODEL_NUMBER, "12345", "U"));
         List<LwM2mObjectEnabler> objects = initializer.createMandatory();
         objects.add(initializer.create(2));
 
         InetSocketAddress clientAddress = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0);
-        LeshanClientBuilder builder = new LeshanClientBuilder(ENDPOINT_IDENTIFIER);
+        LeshanClientBuilder builder = new LeshanClientBuilder(getCurrentEndpoint());
         builder.setLocalAddress(clientAddress.getHostString(), clientAddress.getPort());
         builder.setObjects(objects);
         client = builder.build();
@@ -175,11 +180,12 @@ public class SecureIntegrationTestHelper extends IntegrationTestHelper {
     // TODO implement RPK support for client
     public void createRPKClient() {
         ObjectsInitializer initializer = new ObjectsInitializer();
-        initializer.setInstancesForObject(
-                LwM2mId.SECURITY,
-                Security.rpk("coaps://" + server.getSecureAddress().getHostString() + ":"
-                        + server.getSecureAddress().getPort(), 12345, clientPublicKey.getEncoded(),
-                        clientPrivateKey.getEncoded(), serverPublicKey.getEncoded()));
+        initializer.setInstancesForObject(LwM2mId.SECURITY,
+                Security.rpk(
+                        "coaps://" + server.getSecureAddress().getHostString() + ":"
+                                + server.getSecureAddress().getPort(),
+                        12345, clientPublicKey.getEncoded(), clientPrivateKey.getEncoded(),
+                        serverPublicKey.getEncoded()));
         initializer.setInstancesForObject(LwM2mId.SERVER, new Server(12345, LIFETIME, BindingMode.U, false));
         initializer.setInstancesForObject(LwM2mId.DEVICE, new Device("Eclipse Leshan", MODEL_NUMBER, "12345", "U"));
         List<LwM2mObjectEnabler> objects = initializer.createMandatory();
@@ -194,7 +200,7 @@ public class SecureIntegrationTestHelper extends IntegrationTestHelper {
         CoapServer coapServer = new CoapServer();
         coapServer.addEndpoint(new CoapEndpoint(new DTLSConnector(config.build()), NetworkConfig.getStandard()));
 
-        LeshanClientBuilder builder = new LeshanClientBuilder(ENDPOINT_IDENTIFIER);
+        LeshanClientBuilder builder = new LeshanClientBuilder(getCurrentEndpoint());
         builder.setLocalAddress(clientAddress.getHostString(), clientAddress.getPort());
         builder.setObjects(objects);
         client = builder.build();
@@ -204,10 +210,9 @@ public class SecureIntegrationTestHelper extends IntegrationTestHelper {
     public void createX509CertClient(PrivateKey privatekey, Certificate[] trustedCertificates) {
         ObjectsInitializer initializer = new ObjectsInitializer();
         // TODO security instance with certificate info
-        initializer.setInstancesForObject(
-                LwM2mId.SECURITY,
-                Security.noSec("coaps://" + server.getSecureAddress().getHostString() + ":"
-                        + server.getSecureAddress().getPort(), 12345));
+        initializer.setInstancesForObject(LwM2mId.SECURITY, Security.noSec(
+                "coaps://" + server.getSecureAddress().getHostString() + ":" + server.getSecureAddress().getPort(),
+                12345));
         initializer.setInstancesForObject(LwM2mId.SERVER, new Server(12345, LIFETIME, BindingMode.U, false));
         initializer.setInstancesForObject(LwM2mId.DEVICE, new Device("Eclipse Leshan", MODEL_NUMBER, "12345", "U"));
         List<LwM2mObjectEnabler> objects = initializer.createMandatory();
@@ -222,7 +227,7 @@ public class SecureIntegrationTestHelper extends IntegrationTestHelper {
         CoapServer coapServer = new CoapServer();
         coapServer.addEndpoint(new CoapEndpoint(new DTLSConnector(config.build()), NetworkConfig.getStandard()));
 
-        LeshanClientBuilder builder = new LeshanClientBuilder(ENDPOINT_IDENTIFIER);
+        LeshanClientBuilder builder = new LeshanClientBuilder(getCurrentEndpoint());
         builder.setLocalAddress(clientAddress.getHostString(), clientAddress.getPort());
         builder.setObjects(objects);
         client = builder.build();
@@ -254,21 +259,28 @@ public class SecureIntegrationTestHelper extends IntegrationTestHelper {
         builder.setLocalAddress(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
         builder.setLocalSecureAddress(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
 
-        builder.setSecurityRegistry(new SecurityRegistryImpl(serverPrivateKeyFromCert, serverX509CertChain,
-                trustedCertificates) {
-            // TODO we should separate SecurityRegistryImpl in 2 registries :
-            // InMemorySecurityRegistry and PersistentSecurityRegistry
-            @Override
-            protected void loadFromFile() {
-                // do not load From File
-            }
-
-            @Override
-            protected void saveToFile() {
-                // do not save to file
-            }
-        });
+        builder.setSecurityRegistry(
+                new SecurityRegistryImpl(serverPrivateKeyFromCert, serverX509CertChain, trustedCertificates) {
+                    // TODO we should separate SecurityRegistryImpl in 2 registries :
+                    // InMemorySecurityRegistry and PersistentSecurityRegistry
+                    @Override
+                    protected void loadFromFile() {
+                        // do not load From File
+                    }
+
+                    @Override
+                    protected void saveToFile() {
+                        // do not save to file
+                    }
+                });
 
         server = builder.build();
     }
+
+    @Override
+    public void dispose() {
+        super.dispose();
+        server.getSecurityRegistry().remove(getCurrentEndpoint());
+        server.getSecurityRegistry().remove(BAD_ENDPOINT);
+    }
 }
diff --git a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/SecurityTest.java b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/SecurityTest.java
index 0f2d4848..ce960164 100644
--- a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/SecurityTest.java
+++ b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/SecurityTest.java
@@ -15,12 +15,10 @@
  *******************************************************************************/
 package org.eclipse.leshan.integration.tests;
 
-import static org.eclipse.leshan.integration.tests.IntegrationTestHelper.ENDPOINT_IDENTIFIER;
+
 import static org.eclipse.leshan.integration.tests.IntegrationTestHelper.LIFETIME;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.eclipse.leshan.integration.tests.SecureIntegrationTestHelper.*;
+import static org.junit.Assert.*;
 
 import java.security.PrivateKey;
 import java.security.PublicKey;
@@ -30,117 +28,145 @@ import org.eclipse.leshan.server.client.Client;
 import org.eclipse.leshan.server.security.NonUniqueSecurityInfoException;
 import org.eclipse.leshan.server.security.SecurityInfo;
 import org.junit.After;
+import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
 
 public class SecurityTest {
 
-    private final SecureIntegrationTestHelper helper = new SecureIntegrationTestHelper();
+    protected SecureIntegrationTestHelper helper = new SecureIntegrationTestHelper();
+
+    @Before
+    public void start() {
+        helper.initialize();
+    }
 
     @After
     public void stop() {
         helper.client.stop(true);
         helper.server.destroy();
+        helper.deregisterClient();
+        helper.dispose();
     }
 
     @Test
     public void registered_device_with_psk_to_server_with_psk() throws NonUniqueSecurityInfoException {
+        // Create PSK server & start it
         helper.createServer(); // default server support PSK
         helper.server.start();
 
+        // Create PSK Client
         helper.createPSKClient();
 
+        // Add client credentials to the server
         helper.server.getSecurityRegistry()
-                .add(SecurityInfo.newPreSharedKeyInfo(ENDPOINT_IDENTIFIER, helper.pskIdentity, helper.pskKey));
+                .add(SecurityInfo.newPreSharedKeyInfo(helper.getCurrentEndpoint(), GOOD_PSK_ID, GOOD_PSK_KEY));
+
+        // Check client is not registered
+        helper.assertClientNotRegisterered();
 
+        // Start it and wait for registration
         helper.client.start();
         helper.waitForRegistration(1);
 
-        assertEquals(1, helper.server.getClientRegistry().allClients().size());
-        assertNotNull(helper.server.getClientRegistry().get(ENDPOINT_IDENTIFIER));
+        // Check client is well registered
+        helper.assertClientRegisterered();
     }
 
     @Test
     public void register_update_deregister_reregister_device_with_psk_to_server_with_psk()
             throws NonUniqueSecurityInfoException {
+        // Create PSK server & start it
         helper.createServer(); // default server support PSK
         helper.server.start();
 
+        // Create PSK Client
         helper.createPSKClient();
 
+        // Add client credentials to the server
         helper.server.getSecurityRegistry()
-                .add(SecurityInfo.newPreSharedKeyInfo(ENDPOINT_IDENTIFIER, helper.pskIdentity, helper.pskKey));
+                .add(SecurityInfo.newPreSharedKeyInfo(helper.getCurrentEndpoint(), GOOD_PSK_ID, GOOD_PSK_KEY));
 
-        // Check for registration
+        // Check client is not registered
+        helper.assertClientNotRegisterered();
+
+        // Start it and wait for registration
         helper.client.start();
         helper.waitForRegistration(1);
-        assertEquals(1, helper.server.getClientRegistry().allClients().size());
-        assertNotNull(helper.server.getClientRegistry().get(ENDPOINT_IDENTIFIER));
+
+        // Check client is well registered
+        helper.assertClientRegisterered();
 
         // Check for update
         helper.waitForUpdate(LIFETIME);
-        assertEquals(1, helper.server.getClientRegistry().allClients().size());
+        helper.assertClientRegisterered();
 
         // Check de-registration
         helper.client.stop(true);
         helper.waitForDeregistration(1);
-        assertTrue(helper.server.getClientRegistry().allClients().isEmpty());
+        helper.assertClientNotRegisterered();
 
         // check new registration
         helper.resetLatch();
         helper.client.start();
         helper.waitForRegistration(1);
-        assertEquals(1, helper.server.getClientRegistry().allClients().size());
-        assertNotNull(helper.server.getClientRegistry().get(ENDPOINT_IDENTIFIER));
+        helper.assertClientRegisterered();
     }
 
     @Test
     public void register_update_reregister_device_with_psk_to_server_with_psk() throws NonUniqueSecurityInfoException {
+        // Create PSK server & start it
         helper.createServer(); // default server support PSK
         helper.server.start();
 
+        // Create PSK Client
         helper.createPSKClient();
 
+        // Add client credentials to the server
         helper.server.getSecurityRegistry()
-                .add(SecurityInfo.newPreSharedKeyInfo(ENDPOINT_IDENTIFIER, helper.pskIdentity, helper.pskKey));
+                .add(SecurityInfo.newPreSharedKeyInfo(helper.getCurrentEndpoint(), GOOD_PSK_ID, GOOD_PSK_KEY));
 
         // Check for registration
+        helper.assertClientNotRegisterered();
         helper.client.start();
         helper.waitForRegistration(1);
-        assertEquals(1, helper.server.getClientRegistry().allClients().size());
-        Client registration = helper.server.getClientRegistry().get(ENDPOINT_IDENTIFIER);
-        assertNotNull(registration);
+        Client registration = helper.getCurrentRegistration();
+        helper.assertClientRegisterered();
 
         // Check for update
         helper.waitForUpdate(LIFETIME);
-        assertEquals(1, helper.server.getClientRegistry().allClients().size());
+        helper.assertClientRegisterered();
 
-        // check stop do not de-register
+        // Check stop do not de-register
         helper.client.stop(false);
         helper.waitForDeregistration(1);
-        assertEquals(1, helper.server.getClientRegistry().allClients().size());
+        helper.assertClientRegisterered();
 
-        // check new registration
+        // Check new registration
         helper.resetLatch();
         helper.client.start();
         helper.waitForRegistration(1);
-        Client newRegistration = helper.server.getClientRegistry().get(ENDPOINT_IDENTIFIER);
-        assertEquals(1, helper.server.getClientRegistry().allClients().size());
-        assertNotNull(newRegistration);
+        helper.assertClientRegisterered();
+        Client newRegistration = helper.getCurrentRegistration();
         assertNotEquals(registration.getRegistrationId(), newRegistration.getRegistrationId());
 
     }
 
     @Test
     public void registered_device_with_bad_psk_identity_to_server_with_psk() throws NonUniqueSecurityInfoException {
+        // Create PSK server & start it
         helper.createServer(); // default server support PSK
         helper.server.start();
 
+        // Create PSK Client
         helper.createPSKClient();
 
+        // Add client credentials with BAD PSK ID to the server
         helper.server.getSecurityRegistry()
-                .add(SecurityInfo.newPreSharedKeyInfo(ENDPOINT_IDENTIFIER, "bad_psk_identity", helper.pskKey));
+                .add(SecurityInfo.newPreSharedKeyInfo(helper.getCurrentEndpoint(), BAD_PSK_ID, GOOD_PSK_KEY));
 
+        // Check client can not register
+        helper.assertClientNotRegisterered();
         helper.client.start();
         boolean timedout = !helper.waitForRegistration(1);
 
@@ -149,14 +175,19 @@ public class SecurityTest {
 
     @Test
     public void registered_device_with_bad_psk_key_to_server_with_psk() throws NonUniqueSecurityInfoException {
+        // Create PSK server & start it
         helper.createServer(); // default server support PSK
         helper.server.start();
 
+        // Create PSK Client
         helper.createPSKClient();
 
+        // Add client credentials with BAD PSK KEY to the server
         helper.server.getSecurityRegistry()
-                .add(SecurityInfo.newPreSharedKeyInfo(ENDPOINT_IDENTIFIER, helper.pskIdentity, "bad_key".getBytes()));
+                .add(SecurityInfo.newPreSharedKeyInfo(helper.getCurrentEndpoint(), GOOD_PSK_ID, BAD_PSK_KEY));
 
+        // Check client can not register
+        helper.assertClientNotRegisterered();
         helper.client.start();
         boolean timedout = !helper.waitForRegistration(1);
 
@@ -165,14 +196,19 @@ public class SecurityTest {
 
     @Test
     public void registered_device_with_psk_and_bad_endpoint_to_server_with_psk() throws NonUniqueSecurityInfoException {
+        // Create PSK server & start it
         helper.createServer(); // default server support PSK
         helper.server.start();
 
+        // Create PSK Client
         helper.createPSKClient();
 
+        // Add client credentials for another endpoint to the server
         helper.server.getSecurityRegistry()
-                .add(SecurityInfo.newPreSharedKeyInfo("bad_endpoint", helper.pskIdentity, helper.pskKey));
+                .add(SecurityInfo.newPreSharedKeyInfo(BAD_ENDPOINT, GOOD_PSK_ID, GOOD_PSK_KEY));
 
+        // Check client can not register
+        helper.assertClientNotRegisterered();
         helper.client.start();
         boolean timedout = !helper.waitForRegistration(1);
 
@@ -189,13 +225,13 @@ public class SecurityTest {
         helper.createRPKClient();
 
         helper.server.getSecurityRegistry()
-                .add(SecurityInfo.newRawPublicKeyInfo(ENDPOINT_IDENTIFIER, helper.clientPublicKey));
+                .add(SecurityInfo.newRawPublicKeyInfo(helper.getCurrentEndpoint(), helper.clientPublicKey));
 
         helper.client.start();
         helper.waitForRegistration(1);
 
         assertEquals(1, helper.server.getClientRegistry().allClients().size());
-        assertNotNull(helper.server.getClientRegistry().get(ENDPOINT_IDENTIFIER));
+        assertNotNull(helper.getCurrentRegistration());
     }
 
     @Ignore
@@ -210,7 +246,7 @@ public class SecurityTest {
         // as it is complex to create a public key, I use the server one :p as bad client public key
         PublicKey bad_client_public_key = helper.server.getSecurityRegistry().getServerPublicKey();
         helper.server.getSecurityRegistry()
-                .add(SecurityInfo.newRawPublicKeyInfo(ENDPOINT_IDENTIFIER, bad_client_public_key));
+                .add(SecurityInfo.newRawPublicKeyInfo(helper.getCurrentEndpoint(), bad_client_public_key));
 
         helper.client.start();
         boolean timedout = !helper.waitForRegistration(1);
@@ -245,13 +281,13 @@ public class SecurityTest {
 
         helper.createX509CertClient(helper.clientPrivateKeyFromCert, helper.trustedCertificates);
 
-        helper.server.getSecurityRegistry().add(SecurityInfo.newX509CertInfo(ENDPOINT_IDENTIFIER));
+        helper.server.getSecurityRegistry().add(SecurityInfo.newX509CertInfo(helper.getCurrentEndpoint()));
 
         helper.client.start();
         helper.waitForRegistration(1);
 
         assertEquals(1, helper.server.getClientRegistry().allClients().size());
-        assertNotNull(helper.server.getClientRegistry().get(ENDPOINT_IDENTIFIER));
+        assertNotNull(helper.getCurrentRegistration());
     }
 
     @Ignore
@@ -302,7 +338,7 @@ public class SecurityTest {
         PrivateKey badPrivateKey = helper.serverPrivateKey;
 
         helper.createX509CertClient(badPrivateKey, helper.trustedCertificates);
-        helper.server.getSecurityRegistry().add(SecurityInfo.newX509CertInfo(ENDPOINT_IDENTIFIER));
+        helper.server.getSecurityRegistry().add(SecurityInfo.newX509CertInfo(helper.getCurrentEndpoint()));
 
         helper.client.start();
         boolean timedout = !helper.waitForRegistration(1);
@@ -321,7 +357,7 @@ public class SecurityTest {
 
         helper.createX509CertClient(helper.clientPrivateKeyFromCert, helper.trustedCertificates);
 
-        helper.server.getSecurityRegistry().add(SecurityInfo.newX509CertInfo(ENDPOINT_IDENTIFIER));
+        helper.server.getSecurityRegistry().add(SecurityInfo.newX509CertInfo(helper.getCurrentEndpoint()));
 
         helper.client.start();
         boolean timedout = !helper.waitForRegistration(1);
@@ -339,13 +375,14 @@ public class SecurityTest {
         helper.createX509CertClient(helper.clientPrivateKeyFromCert, helper.trustedCertificates);
 
         helper.server.getSecurityRegistry().add(
-                SecurityInfo.newRawPublicKeyInfo(ENDPOINT_IDENTIFIER, helper.clientX509CertChain[0].getPublicKey()));
+                SecurityInfo.newRawPublicKeyInfo(helper.getCurrentEndpoint(),
+                        helper.clientX509CertChain[0].getPublicKey()));
 
         helper.client.start();
         helper.waitForRegistration(1);
 
         assertEquals(1, helper.server.getClientRegistry().allClients().size());
-        assertNotNull(helper.server.getClientRegistry().get(ENDPOINT_IDENTIFIER));
+        assertNotNull(helper.getCurrentRegistration());
     }
 
     @Ignore
@@ -359,12 +396,12 @@ public class SecurityTest {
         helper.client.start();
 
         helper.server.getSecurityRegistry()
-                .add(SecurityInfo.newRawPublicKeyInfo(ENDPOINT_IDENTIFIER, helper.clientPublicKey));
+                .add(SecurityInfo.newRawPublicKeyInfo(helper.getCurrentEndpoint(), helper.clientPublicKey));
 
         helper.client.start();
         helper.waitForRegistration(1);
 
         assertEquals(1, helper.server.getClientRegistry().allClients().size());
-        assertNotNull(helper.server.getClientRegistry().get(ENDPOINT_IDENTIFIER));
+        assertNotNull(helper.getCurrentRegistration());
     }
 }
diff --git a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/WriteTest.java b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/WriteTest.java
index a6795c43..8c2f9b5d 100644
--- a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/WriteTest.java
+++ b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/WriteTest.java
@@ -18,17 +18,8 @@
 
 package org.eclipse.leshan.integration.tests;
 
-import static org.eclipse.leshan.integration.tests.IntegrationTestHelper.BOOLEAN_RESOURCE_ID;
-import static org.eclipse.leshan.integration.tests.IntegrationTestHelper.FLOAT_RESOURCE_ID;
-import static org.eclipse.leshan.integration.tests.IntegrationTestHelper.INTEGER_RESOURCE_ID;
-import static org.eclipse.leshan.integration.tests.IntegrationTestHelper.OPAQUE_RESOURCE_ID;
-import static org.eclipse.leshan.integration.tests.IntegrationTestHelper.STRING_RESOURCE_ID;
-import static org.eclipse.leshan.integration.tests.IntegrationTestHelper.TEST_OBJECT_ID;
-import static org.eclipse.leshan.integration.tests.IntegrationTestHelper.TIME_RESOURCE_ID;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.eclipse.leshan.integration.tests.IntegrationTestHelper.*;
+import static org.junit.Assert.*;
 
 import java.util.Date;
 import java.util.HashMap;
@@ -56,6 +47,7 @@ public class WriteTest {
 
     @Before
     public void start() {
+        helper.initialize();
         helper.createServer();
         helper.server.start();
         helper.createClient();
@@ -67,6 +59,7 @@ public class WriteTest {
     public void stop() {
         helper.client.stop(false);
         helper.server.stop();
+        helper.dispose();
     }
 
     @Test
@@ -88,14 +81,14 @@ public class WriteTest {
     private void write_string_resource(ContentFormat format) throws InterruptedException {
         // write resource
         final String expectedvalue = "stringvalue";
-        WriteResponse response = helper.server.send(helper.getClient(),
+        WriteResponse response = helper.server.send(helper.getCurrentRegistration(),
                 new WriteRequest(format, TEST_OBJECT_ID, 0, STRING_RESOURCE_ID, expectedvalue));
 
         // verify result
         assertEquals(ResponseCode.CHANGED, response.getCode());
 
         // read resource to check the value changed
-        ReadResponse readResponse = helper.server.send(helper.getClient(),
+        ReadResponse readResponse = helper.server.send(helper.getCurrentRegistration(),
                 new ReadRequest(TEST_OBJECT_ID, 0, STRING_RESOURCE_ID));
         LwM2mResource resource = (LwM2mResource) readResponse.getContent();
         assertEquals(expectedvalue, resource.getValue());
@@ -119,14 +112,14 @@ public class WriteTest {
     private void write_boolean_resource(ContentFormat format) throws InterruptedException {
         // write resource
         final boolean expectedvalue = true;
-        WriteResponse response = helper.server.send(helper.getClient(),
+        WriteResponse response = helper.server.send(helper.getCurrentRegistration(),
                 new WriteRequest(format, TEST_OBJECT_ID, 0, BOOLEAN_RESOURCE_ID, expectedvalue));
 
         // verify result
         assertEquals(ResponseCode.CHANGED, response.getCode());
 
         // read resource to check the value changed
-        ReadResponse readResponse = helper.server.send(helper.getClient(),
+        ReadResponse readResponse = helper.server.send(helper.getCurrentRegistration(),
                 new ReadRequest(TEST_OBJECT_ID, 0, BOOLEAN_RESOURCE_ID));
         LwM2mResource resource = (LwM2mResource) readResponse.getContent();
         assertEquals(expectedvalue, resource.getValue());
@@ -150,14 +143,14 @@ public class WriteTest {
     private void write_integer_resource(ContentFormat format) throws InterruptedException {
         // write resource
         final long expectedvalue = 999l;
-        WriteResponse response = helper.server.send(helper.getClient(),
+        WriteResponse response = helper.server.send(helper.getCurrentRegistration(),
                 new WriteRequest(format, TEST_OBJECT_ID, 0, INTEGER_RESOURCE_ID, expectedvalue));
 
         // verify result
         assertEquals(ResponseCode.CHANGED, response.getCode());
 
         // read resource to check the value changed
-        ReadResponse readResponse = helper.server.send(helper.getClient(),
+        ReadResponse readResponse = helper.server.send(helper.getCurrentRegistration(),
                 new ReadRequest(TEST_OBJECT_ID, 0, INTEGER_RESOURCE_ID));
         LwM2mResource resource = (LwM2mResource) readResponse.getContent();
         assertEquals(expectedvalue, resource.getValue());
@@ -181,14 +174,14 @@ public class WriteTest {
     private void write_float_resource(ContentFormat format) throws InterruptedException {
         // write resource
         final double expectedvalue = 999.99;
-        WriteResponse response = helper.server.send(helper.getClient(),
+        WriteResponse response = helper.server.send(helper.getCurrentRegistration(),
                 new WriteRequest(format, TEST_OBJECT_ID, 0, FLOAT_RESOURCE_ID, expectedvalue));
 
         // verify result
         assertEquals(ResponseCode.CHANGED, response.getCode());
 
         // read resource to check the value changed
-        ReadResponse readResponse = helper.server.send(helper.getClient(),
+        ReadResponse readResponse = helper.server.send(helper.getCurrentRegistration(),
                 new ReadRequest(TEST_OBJECT_ID, 0, FLOAT_RESOURCE_ID));
         LwM2mResource resource = (LwM2mResource) readResponse.getContent();
         assertEquals(expectedvalue, resource.getValue());
@@ -212,14 +205,14 @@ public class WriteTest {
     private void write_time_resource(ContentFormat format) throws InterruptedException {
         // write resource
         final Date expectedvalue = new Date(946681000l); // second accuracy
-        WriteResponse response = helper.server.send(helper.getClient(),
+        WriteResponse response = helper.server.send(helper.getCurrentRegistration(),
                 new WriteRequest(format, TEST_OBJECT_ID, 0, TIME_RESOURCE_ID, expectedvalue));
 
         // verify result
         assertEquals(ResponseCode.CHANGED, response.getCode());
 
         // read resource to check the value changed
-        ReadResponse readResponse = helper.server.send(helper.getClient(),
+        ReadResponse readResponse = helper.server.send(helper.getCurrentRegistration(),
                 new ReadRequest(TEST_OBJECT_ID, 0, TIME_RESOURCE_ID));
         LwM2mResource resource = (LwM2mResource) readResponse.getContent();
         assertEquals(expectedvalue, resource.getValue());
@@ -243,14 +236,14 @@ public class WriteTest {
     private void write_opaque_resource(ContentFormat format) throws InterruptedException {
         // write resource
         final byte[] expectedvalue = new byte[] { 1, 2, 3 };
-        WriteResponse response = helper.server.send(helper.getClient(),
+        WriteResponse response = helper.server.send(helper.getCurrentRegistration(),
                 new WriteRequest(format, TEST_OBJECT_ID, 0, OPAQUE_RESOURCE_ID, expectedvalue));
 
         // verify result
         assertEquals(ResponseCode.CHANGED, response.getCode());
 
         // read resource to check the value changed
-        ReadResponse readResponse = helper.server.send(helper.getClient(),
+        ReadResponse readResponse = helper.server.send(helper.getCurrentRegistration(),
                 new ReadRequest(TEST_OBJECT_ID, 0, OPAQUE_RESOURCE_ID));
         LwM2mResource resource = (LwM2mResource) readResponse.getContent();
         assertArrayEquals(expectedvalue, (byte[]) resource.getValue());
@@ -260,7 +253,7 @@ public class WriteTest {
     public void cannot_write_non_writable_resource() throws InterruptedException {
         // try to write unwritable resource like manufacturer on device
         final String manufacturer = "new manufacturer";
-        WriteResponse response = helper.server.send(helper.getClient(), new WriteRequest(3, 0, 0, manufacturer));
+        WriteResponse response = helper.server.send(helper.getCurrentRegistration(), new WriteRequest(3, 0, 0, manufacturer));
 
         // verify result
         assertEquals(ResponseCode.METHOD_NOT_ALLOWED, response.getCode());
@@ -270,7 +263,7 @@ public class WriteTest {
     public void cannot_write_security_resource() throws InterruptedException {
         // try to write unwritable resource like manufacturer on device
         final String uri = "new.dest.server";
-        WriteResponse response = helper.server.send(helper.getClient(), new WriteRequest(0, 0, 0, uri));
+        WriteResponse response = helper.server.send(helper.getCurrentRegistration(), new WriteRequest(0, 0, 0, uri));
 
         // verify result
         assertEquals(ResponseCode.NOT_FOUND, response.getCode());
@@ -281,14 +274,14 @@ public class WriteTest {
         // write device timezone and offset
         LwM2mResource utcOffset = LwM2mSingleResource.newStringResource(14, "+02");
         LwM2mResource timeZone = LwM2mSingleResource.newStringResource(15, "Europe/Paris");
-        WriteResponse response = helper.server.send(helper.getClient(),
+        WriteResponse response = helper.server.send(helper.getCurrentRegistration(),
                 new WriteRequest(Mode.REPLACE, 3, 0, utcOffset, timeZone));
 
         // verify result
         assertEquals(ResponseCode.CHANGED, response.getCode());
 
         // read the timezone to check the value changed
-        ReadResponse readResponse = helper.server.send(helper.getClient(), new ReadRequest(3, 0));
+        ReadResponse readResponse = helper.server.send(helper.getCurrentRegistration(), new ReadRequest(3, 0));
         LwM2mObjectInstance instance = (LwM2mObjectInstance) readResponse.getContent();
         assertEquals(utcOffset, instance.getResource(14));
         assertEquals(timeZone, instance.getResource(15));
@@ -297,7 +290,7 @@ public class WriteTest {
     @Test
     public void can_write_replacing_object_instance() throws InterruptedException {
         // setup server object
-        WriteResponse response = helper.server.send(helper.getClient(), new WriteRequest(1, 0, 3, 60));
+        WriteResponse response = helper.server.send(helper.getCurrentRegistration(), new WriteRequest(1, 0, 3, 60));
 
         // verify result
         assertEquals(ResponseCode.CHANGED, response.getCode());
@@ -307,14 +300,14 @@ public class WriteTest {
         LwM2mResource defaultMinPeriod = LwM2mSingleResource.newIntegerResource(2, 10);
         LwM2mResource notificationStoring = LwM2mSingleResource.newBooleanResource(6, false);
         LwM2mResource binding = LwM2mSingleResource.newStringResource(7, "U");
-        response = helper.server.send(helper.getClient(),
+        response = helper.server.send(helper.getCurrentRegistration(),
                 new WriteRequest(Mode.REPLACE, 1, 0, lifetime, defaultMinPeriod, notificationStoring, binding));
 
         // verify result
         assertEquals(ResponseCode.CHANGED, response.getCode());
 
         // read the values to check the value changed
-        ReadResponse readResponse = helper.server.send(helper.getClient(), new ReadRequest(1, 0));
+        ReadResponse readResponse = helper.server.send(helper.getCurrentRegistration(), new ReadRequest(1, 0));
         LwM2mObjectInstance instance = (LwM2mObjectInstance) readResponse.getContent();
         assertEquals(lifetime, instance.getResource(1));
         assertEquals(defaultMinPeriod, instance.getResource(2));
@@ -328,7 +321,7 @@ public class WriteTest {
         // write server object
         LwM2mResource lifetime = LwM2mSingleResource.newIntegerResource(1, 120);
         LwM2mResource defaultMinPeriod = LwM2mSingleResource.newIntegerResource(2, 10);
-        WriteResponse response = helper.server.send(helper.getClient(),
+        WriteResponse response = helper.server.send(helper.getCurrentRegistration(),
                 new WriteRequest(Mode.REPLACE, 1, 0, lifetime, defaultMinPeriod));
 
         // verify result
@@ -338,21 +331,21 @@ public class WriteTest {
     @Test
     public void can_write_updating_object_instance() throws InterruptedException {
         // setup server object
-        WriteResponse response = helper.server.send(helper.getClient(), new WriteRequest(1, 0, 3, 60));
+        WriteResponse response = helper.server.send(helper.getCurrentRegistration(), new WriteRequest(1, 0, 3, 60));
 
         // verify result
         assertEquals(ResponseCode.CHANGED, response.getCode());
         // write server object
         LwM2mResource lifetime = LwM2mSingleResource.newIntegerResource(1, 120);
         LwM2mResource defaultMinPeriod = LwM2mSingleResource.newIntegerResource(2, 10);
-        response = helper.server.send(helper.getClient(),
+        response = helper.server.send(helper.getCurrentRegistration(),
                 new WriteRequest(Mode.UPDATE, 1, 0, lifetime, defaultMinPeriod));
 
         // verify result
         assertEquals(ResponseCode.CHANGED, response.getCode());
 
         // read the values to check the value changed
-        ReadResponse readResponse = helper.server.send(helper.getClient(), new ReadRequest(1, 0));
+        ReadResponse readResponse = helper.server.send(helper.getCurrentRegistration(), new ReadRequest(1, 0));
         LwM2mObjectInstance instance = (LwM2mObjectInstance) readResponse.getContent();
         assertEquals(lifetime, instance.getResource(1));
         assertEquals(defaultMinPeriod, instance.getResource(2));
@@ -367,14 +360,14 @@ public class WriteTest {
         // write device timezone and offset
         LwM2mResource utcOffset = LwM2mSingleResource.newStringResource(14, "+02");
         LwM2mResource timeZone = LwM2mSingleResource.newStringResource(15, "Europe/Paris");
-        WriteResponse response = helper.server.send(helper.getClient(),
+        WriteResponse response = helper.server.send(helper.getCurrentRegistration(),
                 new WriteRequest(Mode.REPLACE, ContentFormat.JSON, 3, 0, utcOffset, timeZone));
 
         // verify result
         assertEquals(ResponseCode.CHANGED, response.getCode());
 
         // read the timezone to check the value changed
-        ReadResponse readResponse = helper.server.send(helper.getClient(), new ReadRequest(3, 0));
+        ReadResponse readResponse = helper.server.send(helper.getCurrentRegistration(), new ReadRequest(3, 0));
         LwM2mObjectInstance instance = (LwM2mObjectInstance) readResponse.getContent();
         assertEquals(utcOffset, instance.getResource(14));
         assertEquals(timeZone, instance.getResource(15));
@@ -388,7 +381,7 @@ public class WriteTest {
         neighbourCellReport.put(2, new ObjectLink(10244, 3));
 
         // Write objlnk resource in TLV format
-        WriteResponse response = helper.server.send(helper.getClient(),
+        WriteResponse response = helper.server.send(helper.getCurrentRegistration(),
                 new WriteRequest(ContentFormat.TLV, IntegrationTestHelper.TEST_OBJECT_ID, 0,
                         IntegrationTestHelper.OBJLNK_MULTI_INSTANCE_RESOURCE_ID, neighbourCellReport, Type.OBJLNK));
 
@@ -396,7 +389,7 @@ public class WriteTest {
         assertEquals(ResponseCode.CHANGED, response.getCode());
 
         // Reading back the written OBJLNK value
-        ReadResponse readResponse = helper.server.send(helper.getClient(), new ReadRequest(
+        ReadResponse readResponse = helper.server.send(helper.getCurrentRegistration(), new ReadRequest(
                 IntegrationTestHelper.TEST_OBJECT_ID, 0, IntegrationTestHelper.OBJLNK_MULTI_INSTANCE_RESOURCE_ID));
         LwM2mMultipleResource resource = (LwM2mMultipleResource) readResponse.getContent();
 
@@ -414,7 +407,7 @@ public class WriteTest {
         ObjectLink data = new ObjectLink(10245, 1);
 
         // Write objlnk resource in TLV format
-        WriteResponse response = helper.server.send(helper.getClient(),
+        WriteResponse response = helper.server.send(helper.getCurrentRegistration(),
                 new WriteRequest(ContentFormat.TLV, IntegrationTestHelper.TEST_OBJECT_ID, 0,
                         IntegrationTestHelper.OBJLNK_SINGLE_INSTANCE_RESOURCE_ID, data));
 
@@ -422,7 +415,7 @@ public class WriteTest {
         assertEquals(ResponseCode.CHANGED, response.getCode());
 
         // Reading back the written OBJLNK value
-        ReadResponse readResponse = helper.server.send(helper.getClient(), new ReadRequest(
+        ReadResponse readResponse = helper.server.send(helper.getCurrentRegistration(), new ReadRequest(
                 IntegrationTestHelper.TEST_OBJECT_ID, 0, IntegrationTestHelper.OBJLNK_SINGLE_INSTANCE_RESOURCE_ID));
         LwM2mSingleResource resource = (LwM2mSingleResource) readResponse.getContent();
 
@@ -434,7 +427,7 @@ public class WriteTest {
     @Test
     public void can_write_single_instance_objlnk_resource_in_text() throws InterruptedException {
         // Write objlnk resource in TEXT format
-        WriteResponse response = helper.server.send(helper.getClient(),
+        WriteResponse response = helper.server.send(helper.getCurrentRegistration(),
                 new WriteRequest(ContentFormat.TEXT, IntegrationTestHelper.TEST_OBJECT_ID, 0,
                         IntegrationTestHelper.OBJLNK_SINGLE_INSTANCE_RESOURCE_ID, new ObjectLink(10245, 0)));
 
@@ -442,11 +435,10 @@ public class WriteTest {
         assertEquals(ResponseCode.CHANGED, response.getCode());
 
         // Reading back the written OBJLNK value
-        ReadResponse readResponse = helper.server.send(helper.getClient(), new ReadRequest(ContentFormat.TEXT,
+        ReadResponse readResponse = helper.server.send(helper.getCurrentRegistration(), new ReadRequest(ContentFormat.TEXT,
                 IntegrationTestHelper.TEST_OBJECT_ID, 0, IntegrationTestHelper.OBJLNK_SINGLE_INSTANCE_RESOURCE_ID));
         LwM2mSingleResource resource = (LwM2mSingleResource) readResponse.getContent();
 
-        System.out.println(resource.getValue().toString());
         // verify read value
         assertEquals(((ObjectLink) resource.getValue()).getObjectId(), 10245);
         assertEquals(((ObjectLink) resource.getValue()).getObjectInstanceId(), 0);