PentahoSecurityContextHolderStrategy implements SecurityContextHolderStrategy { public SecurityContext getContext() { if ( context.get() == null ) { context.set( new PentahoSecurityContextImpl() ); } return context.get(); }  SecurityContext getContext(); void setContext( SecurityContext sContext ); @Override void clearContext(); @Override SecurityContext createEmptyContext();  }
@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() ); }