Program: 29372
Project: 29372
Buggy source:
@Test public void addElementTest() throws TransactionFailure {
  final Domain domain=getHabitat().getService(Domain.class);
  final ConfigListener configListener=new ConfigListener(){
    @Override public UnprocessedChangeEvents changed(    PropertyChangeEvent[] propertyChangeEvents){
      events=Arrays.asList(propertyChangeEvents);
      return null;
    }
  }
;
  Transactions transactions=getHabitat().getService(Transactions.class);
  try {
    transactions.addListenerForType(SystemProperty.class,configListener);
    assertTrue(domain != null);
    ConfigSupport.apply(new SingleConfigCode<Domain>(){
      public Object run(      Domain domain) throws PropertyVetoException, TransactionFailure {
        SystemProperty prop=domain.createChild(SystemProperty.class);
        domain.getSystemProperty().add(prop);
        prop.setName("String_Node_Str");
        prop.setValue("String_Node_Str");
        return prop;
      }
    }
,domain);
    transactions.waitForDrain();
    assertTrue(events != null);
    logger.fine("String_Node_Str" + events.size());
    assertTrue(events.size() == 3);
    for (    PropertyChangeEvent event : events) {
      logger.fine(event.toString());
    }
    events=null;
    for (    SystemProperty prop : domain.getSystemProperty()) {
      if (prop.getName().equals("String_Node_Str")) {
        ConfigSupport.apply(new SingleConfigCode<SystemProperty>(){
          @Override public Object run(          SystemProperty param) throws PropertyVetoException, TransactionFailure {
            param.setValue("String_Node_Str");
            return null;
          }
        }
,prop);
        break;
      }
    }
    assertTrue(events != null);
    logger.fine("String_Node_Str" + events.size());
    assertTrue(events.size() == 1);
    for (    PropertyChangeEvent event : events) {
      logger.fine(event.toString());
    }
    events=null;
    assertNotNull(ConfigSupport.apply(new SingleConfigCode<Domain>(){
      public Object run(      Domain domain) throws PropertyVetoException, TransactionFailure {
        for (        SystemProperty prop : domain.getSystemProperty()) {
          if (prop.getName().equals("String_Node_Str")) {
            domain.getSystemProperty().remove(prop);
            return prop;
          }
        }
        return null;
      }
    }
,domain));
    transactions.waitForDrain();
    assertTrue(events != null);
    logger.fine("String_Node_Str" + events.size());
    assertTrue(events.size() == 1);
    for (    PropertyChangeEvent event : events) {
      logger.fine(event.toString());
    }
  }
  finally {
    assertTrue(transactions.removeListenerForType(SystemProperty.class,configListener));
  }
}

Fixed version (ground truth):
@Test public void addElementTest() throws TransactionFailure {
  final Domain domain=getHabitat().getService(Domain.class);
  final ConfigListener configListener=new ConfigListener(){
    @Override public UnprocessedChangeEvents changed(    PropertyChangeEvent[] propertyChangeEvents){
      events=Arrays.asList(propertyChangeEvents);
      return null;
    }
  }
;
  Transactions transactions=getHabitat().getService(Transactions.class);
  try {
    transactions.addListenerForType(SystemProperty.class,configListener);
    assertTrue(domain != null);
    ConfigSupport.apply(new SingleConfigCode<Domain>(){
      @Override public Object run(      Domain domain) throws PropertyVetoException, TransactionFailure {
        SystemProperty prop=domain.createChild(SystemProperty.class);
        domain.getSystemProperty().add(prop);
        prop.setName("String_Node_Str");
        prop.setValue("String_Node_Str");
        return prop;
      }
    }
,domain);
    transactions.waitForDrain();
    assertTrue(events != null);
    logger.log(Level.FINE,"String_Node_Str",events.size());
    assertTrue(events.size() == 3);
    for (    PropertyChangeEvent event : events) {
      logger.fine(event.toString());
    }
    events=null;
    for (    SystemProperty prop : domain.getSystemProperty()) {
      if (prop.getName().equals("String_Node_Str")) {
        ConfigSupport.apply(new SingleConfigCode<SystemProperty>(){
          @Override public Object run(          SystemProperty param) throws PropertyVetoException, TransactionFailure {
            param.setValue("String_Node_Str");
            return null;
          }
        }
,prop);
        break;
      }
    }
    assertTrue(events != null);
    logger.log(Level.FINE,"String_Node_Str",events.size());
    assertTrue(events.size() == 1);
    for (    PropertyChangeEvent event : events) {
      logger.fine(event.toString());
    }
    events=null;
    assertNotNull(ConfigSupport.apply(new SingleConfigCode<Domain>(){
      @Override public Object run(      Domain domain) throws PropertyVetoException, TransactionFailure {
        for (        SystemProperty prop : domain.getSystemProperty()) {
          if (prop.getName().equals("String_Node_Str")) {
            domain.getSystemProperty().remove(prop);
            return prop;
          }
        }
        return null;
      }
    }
,domain));
    transactions.waitForDrain();
    assertTrue(events != null);
    logger.log(Level.FINE,"String_Node_Str",events.size());
    assertTrue(events.size() == 1);
    for (    PropertyChangeEvent event : events) {
      logger.fine(event.toString());
    }
  }
  finally {
    assertTrue(transactions.removeListenerForType(SystemProperty.class,configListener));
  }
}