public class StatefulSecurityPermissionsTest extends TestCase {
public void test() throws Exception {
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
Assembler assembler = new Assembler();
ConfigurationFactory config = new ConfigurationFactory();
assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
SecurityServiceInfo securityServiceInfo = config.configureService(SecurityServiceInfo.class);
securityServiceInfo.className = TestSecurityService.class.getName();
assembler.createSecurityService(securityServiceInfo);
TestSecurityService securityService = (TestSecurityService) SystemInstance.get().getComponent(SecurityService.class);
securityService.login("foo", "Jazz", "Rock", "Reggae", "HipHop");
EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new StatefulBean(Color.class));
List<MethodPermission> permissions = ejbJar.getAssemblyDescriptor().getMethodPermission();
permissions.add(new MethodPermission("*", "Color", "*", "Foo"));
permissions.add(new MethodPermission("*", "Color", "create").setUnchecked());
permissions.add(new MethodPermission("*", "Color", "ejbCreate").setUnchecked());
EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
assembler.createApplication(ejbJarInfo);
InitialContext context = new InitialContext();
{
ColorLocal color = (ColorLocal) context.lookup("ColorLocal");