InMemoryRegistrationStore implements CaliforniumRegistrationStore, Startable, Stoppable, Destroyable { @Override public Deregistration addRegistration(Registration registration) { try { lock.writeLock().lock(); Registration registrationRemoved = regsByEp.put(registration.getEndpoint(), registration); regsByRegId.put(registration.getId(), registration); regsByAddr.put(registration.getSocketAddress(), registration); if (registrationRemoved != null) { Collection<Observation> observationsRemoved = unsafeRemoveAllObservations(registrationRemoved.getId()); if (!registrationRemoved.getSocketAddress().equals(registration.getSocketAddress())) { removeFromMap(regsByAddr, registrationRemoved.getSocketAddress(), registrationRemoved); } if (!registrationRemoved.getId().equals(registration.getId())) { removeFromMap(regsByRegId, registrationRemoved.getId(), registrationRemoved); } return new Deregistration(registrationRemoved, observationsRemoved); } } finally { lock.writeLock().unlock(); } return null; } InMemoryRegistrationStore();  InMemoryRegistrationStore(long cleanPeriodInSec);  InMemoryRegistrationStore(ScheduledExecutorService schedExecutor, long cleanPeriodInSec); @Override Deregistration addRegistration(Registration registration); @Override UpdatedRegistration updateRegistration(RegistrationUpdate update); @Override Registration getRegistration(String registrationId); @Override Registration getRegistrationByEndpoint(String endpoint); @Override Registration getRegistrationByAdress(InetSocketAddress address); @Override Iterator<Registration> getAllRegistrations(); @Override Deregistration removeRegistration(String registrationId); @Override Collection<Observation> addObservation(String registrationId, Observation observation); @Override Observation removeObservation(String registrationId, byte[] observationId); @Override Observation getObservation(String registrationId, byte[] observationId); @Override Collection<Observation> getObservations(String registrationId); @Override Collection<Observation> removeObservations(String registrationId); @Override org.eclipse.californium.core.observe.Observation putIfAbsent(Token token,
            org.eclipse.californium.core.observe.Observation obs); @Override org.eclipse.californium.core.observe.Observation put(Token token,
            org.eclipse.californium.core.observe.Observation obs); @Override org.eclipse.californium.core.observe.Observation get(Token token); @Override void setContext(Token token, EndpointContext ctx); @Override void remove(Token token); @Override void setExpirationListener(ExpirationListener listener); @Override synchronized void start(); @Override synchronized void stop(); @Override synchronized void destroy(); @Override void setExecutor(ScheduledExecutorService executor);  }
@Test public void client_registration_sets_time_to_live() { givenASimpleRegistration(lifetime); store.addRegistration(registration); Assert.assertTrue(registration.isAlive()); }