### Question:
ServiceInfoCache { public Result<T> remove(ServiceInfo.Key key) { T previous = null; lock(); try { ServiceType serviceType = keysToServiceTypes.remove(key); if (serviceType == null) return new Result<T>(null, null); previous = keysToServiceInfos.remove(key); previous.setRegistered(false); } finally { unlock(); } notifyServiceRemoved(previous, null); return new Result<T>(previous, null); }  void lock(); void unlock(); void addServiceListener(ServiceListener listener); void removeServiceListener(ServiceListener listener); Result<T> put(T service); int getSize(); T get(ServiceInfo.Key key); Result<T> addAttributes(ServiceInfo.Key key, Attributes attributes); Result<T> removeAttributes(ServiceInfo.Key key, Attributes attributes); Result<T> remove(ServiceInfo.Key key); List<T> match(ServiceType serviceType, String language, Scopes scopes, Filter filter); List<T> getServiceInfos(); List<T> purge();  }### Answer:
@Test public void testRemove() throws Exception { ServiceInfoCache<ServiceInfo> cache = new ServiceInfoCache<ServiceInfo>(); ServiceURL serviceURL = new ServiceURL("service:foo:bar: Attributes attributes1 = Attributes.from("(attr=sict1),tag"); Scopes scopes = Scopes.from("scope1"); ServiceInfo serviceInfo1 = new ServiceInfo(serviceURL, Locale.ENGLISH.getLanguage(), scopes, attributes1); cache.put(serviceInfo1); ServiceInfoCache.Result<ServiceInfo> result = cache.remove(serviceInfo1.getKey()); assert result.getPrevious() == serviceInfo1; assert result.getCurrent() == null; assert cache.getSize() == 0; }