Hi All,

I am putting some unit tests together and am running upon an oddity that I don't understand (and trying to tell myself that WebObjects isn't being end-of-lifed because everything is "legacy" documentation - I'm freaking out!). Anyways, if I do this:

public class PurchasingTest extends XTest {
        
        public class ECLogger{
                public void logECMsg(NSNotification n){
                        Logger.getLogger(this.getClass()).debug("EC sent " + 
n.name());
                }
        }
        
        @Test
        public void simpleECChangeTest(){
                EOEditingContext ec = ERXEC.newEditingContext();
                ec.lock();
                NSNotificationCenter.defaultCenter().addObserver(new ECLogger(),
                                new NSSelector("logECMsg", new 
Class[]{NSNotification.class}),
                                null,
                                ec);
                User user = Utils.newEntityForClass(ec, User.class);
                ec.saveChanges();
        //      NSNotificationCenter.defaultCenter().addObserver(new ECLogger(),
        //                      new NSSelector("logECMsg", new 
Class[]{NSNotification.class}),
        //                      null,
        //                      ec);
                user.setNickname("friend");
                ec.saveChanges();
                ec.unlock();
        }
}

I get nothing in the log. If I switch the comments to add the observer at the latter spot, then I get this in the console, which looks okay to me:

7170 [main] DEBUG tests.PurchasingTest$ECLogger - EC sent EOEditingContextWillSaveChanges 7171 [main] DEBUG tests.PurchasingTest$ECLogger - EC sent EOObjectsChangedInStoreNotification 7171 [main] DEBUG tests.PurchasingTest$ECLogger - EC sent EOObjectsChangedInEditingContextNotification 7171 [main] DEBUG tests.PurchasingTest$ECLogger - EC sent ObjectsWillChangeInEditingContext 7181 [main] DEBUG tests.PurchasingTest$ECLogger - EC sent EOEditingContextDidSaveChangesNotification 7183 [main] DEBUG tests.PurchasingTest$ECLogger - EC sent EOObjectsChangedInStoreNotification 7183 [main] DEBUG tests.PurchasingTest$ECLogger - EC sent EOObjectsChangedInEditingContextNotification

I don't get it. Any ideas? I thought maybe it had something to do with the save, but the fact is that I am running the exact same routine with the same EO data and everything. The only thing that is different is where I add the observer. I am on 5.3 still and using Wonder for 5.3.

Thanks in advance,
John
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to