}
}
+ public static final class MyTypeConfig extends ConfigImpl<MyType> {
+ public MyTypeConfig(Id<Config> aId) {
+ super(aId);
+ }
+
+ public MyTypeConfig(MyTypeConfig aConfig) {
+ super(aConfig);
+ }
+
+ @Override
+ public MyType wrap(String aPrefix, MyType aT) {
+ return new MyTypeWrapper(aPrefix, aT);
+ }
+ }
+
private AtomicLong sequence;
- private ExtendedConfig<MyType> config;
+ private MyTypeConfig config;
@Before
public void setUp() {
sequence = new AtomicLong(1L);
- config = new ConfigImpl<MyType>(new Id<Config>(CONFIG_TYPE)) {
- @Override
- public MyType wrap(String aPrefix, MyType aT) {
- return new MyTypeWrapper(aPrefix, aT);
- }
- };
+ config = new MyTypeConfig(new Id<Config>(CONFIG_TYPE));
}
@Test
assertTrue(config2.remove(type2.getId()));
assertFalse(config1.equals(config2));
}
+
+ @Test
+ public void testCopy() {
+ testAdd();
+ assertEquals(2, config.values().size());
+ MyTypeConfig copy = new MyTypeConfig(config);
+ assertEquals(config.getId(), config.getId());
+ assertEquals(config, copy);
+
+ // verify the copy is not shallow
+ assertTrue(config.remove(new Id<MyType>("type1")));
+ assertEquals(1, config.values().size());
+ assertFalse(config.equals(copy));
+ }
}