### Question:
DefaultAttributeMap implements AttributeMap { @Override public <T> Attribute<T> attr(AttributeKey<T> key) { Map<AttributeKey<?>, Attribute<?>> map = this.map; if (map == null) { map = new IdentityHashMap<AttributeKey<?>, Attribute<?>>(2); if (!updater.compareAndSet(this, null, map)) { map = this.map; } } synchronized (map) { @SuppressWarnings("unchecked") Attribute<T> attr = (Attribute<T>) map.get(key); if (attr == null) { attr = new DefaultAttribute<T>(map, key); map.put(key, attr); } return attr; } }  @Override Attribute<T> attr(AttributeKey<T> key);  }### Answer:
@Test public void testGetSetString() { AttributeKey<String> key = AttributeKey.valueOf("Nothing"); Attribute<String> one = map.attr(key); assertSame(one, map.attr(key)); one.setIfAbsent("Whoohoo"); assertSame(one.get(), "Whoohoo"); one.setIfAbsent("What"); assertNotSame(one.get(), "What"); one.remove(); assertNull(one.get()); }
@Test public void testGetSetInt() { AttributeKey<Integer> key = AttributeKey.valueOf("Nada"); Attribute<Integer> one = map.attr(key); assertSame(one, map.attr(key)); one.setIfAbsent(3653); assertEquals(one.get(), Integer.valueOf(3653)); one.setIfAbsent(1); assertNotSame(one.get(), 1); one.remove(); assertNull(one.get()); }