void () { getTypeChooserManager().registerTypeChooser(MyAbstractElement.class, new MyTypeChooser()); try { MyElement element = createElement("<a>" + "<abstract-child>Foo</abstract-child>" + "<abstract-element>Foo</abstract-element>" + "<abstract-element>bar</abstract-element>" + "</a>"); assertFalse(element.getAbstractChild()instanceof MyBarConcreteElement); final List<MyAbstractElement> abstractElements = element.getAbstractElements(); assertTrue(abstractElements.get(0)instanceof MyFooConcreteElement); assertTrue(abstractElements.get(1)instanceof MyBarConcreteElement); } finally { getTypeChooserManager().unregisterTypeChooser(MyAbstractElement.class); } }