Wishing for "let rec" in Java

April 15, 2010
     public void testCallsRollbackIfSendingAuthResponseFails() throws Exception {
         final MockSender sender = new MockSender();
         final MockSession session = new MockSession() {
             @Override
             public DASAuthObj authorize(final DASAuthObj authObj) {
                 mgr.dispatch( ... // AGHAGHAGH!
                 return super.authorize(authObj);
             }
         };
         final DASSessionManager mgr = new DASSessionManager(session, sender);
         ...

[EDIT: OK, you can do it manually with Java arrays. Still icky.]

     public void testCallsRollbackIfSendingAuthResponseFails() throws Exception {
         final MockSender sender = new MockSender();
         final DASSessionManager[] mgrHolder = new DASSessionManager[1];
         final MockSession session = new MockSession() {
             @Override
             public DASAuthObj authorize(final DASAuthObj authObj) {
                 mgrHolder[0].dispatch(new DASCloseAuthSinkPacket(1, true, 42));
                 return super.authorize(authObj);
             }
         };
         final DASSessionManager mgr = new DASSessionManager(session, sender);
         mgrHolder[0] = mgr;
Tags: java fixme