OrderedProperties extends Properties { @Override public synchronized Object remove(Object key) { if (key instanceof String) { this.propertyNames.remove(key); } return super.remove(key); } OrderedProperties(); @Override synchronized Object put(Object key, Object value); @Override Set<String> stringPropertyNames(); @Override Enumeration<?> propertyNames(); @Override synchronized Enumeration<Object> keys(); @Override Set<Object> keySet(); @Override Set<Entry<Object, Object>> entrySet(); @Override synchronized void putAll(Map<?, ?> t); @Override synchronized void clear(); @Override synchronized Object remove(Object key);  }
@Test public void testRemove() { Object value1 = orderedProperties.remove("key1"); assertEquals("value1", value1); value1 = orderedProperties.remove("key1"); assertNull(value1); assertNull(orderedProperties.get("key1")); assertFalse(orderedProperties.containsKey("key1")); }