TextField field = new TextField("field");
// Test that adding behavior registers control as ajax target
assertFalse(registry.hasAjaxTargetControls());
field.addBehavior(new DefaultAjaxBehavior());
assertTrue(registry.hasAjaxTargetControls());
assertEquals(1, registry.getAjaxTargetControls().size());
// Test that adding another behavior does not register the control twice
field.addBehavior(new DefaultAjaxBehavior());
assertEquals(1, registry.getAjaxTargetControls().size());
// Test that invoking onInit does not register the control twice
field.onInit();
assertEquals(1, registry.getAjaxTargetControls().size());