@Override public void run() { assertSame( authentication, strategy.getContext().getAuthentication() ); Authentication authentication2 = mock( Authentication.class ); strategy.getContext().setAuthentication( authentication2 ); assertSame( authentication2, strategy.getContext().getAuthentication() ); doneSignal.countDown(); } });
@Test public void testGetContext() throws Exception { final PentahoSecurityContextHolderStrategy strategy = new PentahoSecurityContextHolderStrategy(); SecurityContext context = strategy.getContext(); assertNotNull( context ); final Authentication authentication = mock( Authentication.class ); context.setAuthentication( authentication ); final CountDownLatch doneSignal = new CountDownLatch( 1 ); assertSame( authentication, strategy.getContext().getAuthentication() ); Thread thread = new Thread( new Runnable() { @Override public void run() { assertSame( authentication, strategy.getContext().getAuthentication() ); Authentication authentication2 = mock( Authentication.class ); strategy.getContext().setAuthentication( authentication2 ); assertSame( authentication2, strategy.getContext().getAuthentication() ); doneSignal.countDown(); } }); thread.start(); doneSignal.await(); assertSame( authentication, strategy.getContext().getAuthentication() ); } }