final String category = "test" ;
final String service = "authenticationRequestPropagation" ;
final MockCourier mockCourier = new PropagationMockCourier() ;
MockRegistry.register(category, service, mockCourier) ;
final ServiceInvoker si = new ServiceInvoker(category, service) ;
final Message message = MessageFactory.getInstance().getMessage() ;
assertNull("authenticationRequest", AuthenticationRequestImpl.getEncryptedAuthRequest()) ;
assertNull("message context", message.getContext().getContext(SecurityService.AUTH_REQUEST)) ;
final byte[] authenticationRequest = new byte[0] ;
AuthenticationRequestImpl.setEncryptedAuthRequest(authenticationRequest) ;
assertNotNull("authenticationRequest", AuthenticationRequestImpl.getEncryptedAuthRequest()) ;
si.deliverAsync(message) ;
assertNotSame("messages", message, mockCourier.message) ;
assertNull("message context", message.getContext().getContext(SecurityService.AUTH_REQUEST)) ;
assertNotNull("delivered message context", mockCourier.message.getContext().getContext(SecurityService.AUTH_REQUEST)) ;
assertNotNull("authenticationRequest", AuthenticationRequestImpl.getEncryptedAuthRequest()) ;
mockCourier.reset();
si.deliverAsync(message) ;
assertNotSame("messages", message, mockCourier.message) ;
assertNull("message context", message.getContext().getContext(SecurityService.AUTH_REQUEST)) ;
assertNotNull("delivered message context", mockCourier.message.getContext().getContext(SecurityService.AUTH_REQUEST)) ;
assertNotNull("authenticationRequest", AuthenticationRequestImpl.getEncryptedAuthRequest()) ;