final ConsoleImpl console = new ConsoleImpl(null, new ThreadIOImpl(), System.in, System.out, System.err, null, "UTF-8", null, bc, true);
assertTrue(console.session instanceof DelegateSession);
console.session.put("foo", "bar");
final DelegateSession ds = (DelegateSession) console.session;
assertNull("Precondition", ds.delegate);
Subject subject = new Subject();
subject.getPrincipals().add(new RolePrincipal("myrole"));
Subject.doAs(subject, new PrivilegedAction<Object>() {
@Override
public Object run() {
SecuredCommandProcessorImpl secCP = console.createSecuredCommandProcessor();
assertNotNull(ds.delegate);
assertEquals("Attributes set before the delegate was set should have been transferred",
"bar", ds.get("foo"));
assertEquals("Attributes set before the delegate was set should have been transferred",
"bar", ds.delegate.get("foo"));
assertSame(System.out, ds.delegate.getConsole());
assertSame(System.out, ds.getConsole());
assertTrue(secCP.getCommands().contains("myscope:myfunction"));
return null;
}