You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by an...@apache.org on 2013/11/21 15:57:40 UTC

svn commit: r1544204 - in /tomee/tomee/trunk/container/openejb-core/src: main/java/org/apache/openejb/assembler/classic/ main/java/org/apache/openejb/core/ivm/naming/ test/java/org/apache/openejb/core/asynch/ test/java/org/apache/openejb/core/security/...

Author: andygumbrecht
Date: Thu Nov 21 14:57:40 2013
New Revision: 1544204

URL: http://svn.apache.org/r1544204
Log:
Finals and cleanups.
Added AsynchInRoleTest

Added:
    tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/core/asynch/AsynchInRoleTest.java
      - copied, changed from r1544085, tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/core/asynch/AsynchTest.java
Modified:
    tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JaccPermissionsBuilder.java
    tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/InitContextFactory.java
    tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/core/asynch/AsynchTest.java
    tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/core/security/ServiceProviderLoginModuleTest.java
    tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/StatefulTransactionAttributesTest.java

Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JaccPermissionsBuilder.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JaccPermissionsBuilder.java?rev=1544204&r1=1544203&r2=1544204&view=diff
==============================================================================
--- tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JaccPermissionsBuilder.java (original)
+++ tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JaccPermissionsBuilder.java Thu Nov 21 14:57:40 2013
@@ -48,19 +48,21 @@ public class JaccPermissionsBuilder {
         System.setProperty("org.apache.security.jacc.EJBMethodPermission.methodInterfaces", "BusinessLocalHome,BusinessRemoteHome,BusinessRemote,BusinessLocal");
     }
 
-    public void install(PolicyContext policyContext) throws OpenEJBException {
-        if (SystemInstance.get().hasProperty("openejb.geronimo")) return;
+    public void install(final PolicyContext policyContext) throws OpenEJBException {
+        if (SystemInstance.get().hasProperty("openejb.geronimo")) {
+            return;
+        }
 
         try {
-            PolicyConfigurationFactory factory = PolicyConfigurationFactory.getPolicyConfigurationFactory();
+            final PolicyConfigurationFactory factory = PolicyConfigurationFactory.getPolicyConfigurationFactory();
 
-            PolicyConfiguration policy = factory.getPolicyConfiguration(policyContext.getContextID(), false);
+            final PolicyConfiguration policy = factory.getPolicyConfiguration(policyContext.getContextID(), false);
 
             policy.addToExcludedPolicy(policyContext.getExcludedPermissions());
 
             policy.addToUncheckedPolicy(policyContext.getUncheckedPermissions());
 
-            for (Map.Entry<String, PermissionCollection> entry : policyContext.getRolePermissions().entrySet()) {
+            for (final Map.Entry<String, PermissionCollection> entry : policyContext.getRolePermissions().entrySet()) {
                 policy.addToRole(entry.getKey(), entry.getValue());
             }
 
@@ -72,16 +74,16 @@ public class JaccPermissionsBuilder {
         }
     }
 
-    private static Logger log = Logger.getInstance(LogCategory.OPENEJB_STARTUP.createChild("attributes"), JaccPermissionsBuilder.class);
+    private static final Logger log = Logger.getInstance(LogCategory.OPENEJB_STARTUP.createChild("attributes"), JaccPermissionsBuilder.class);
 
-    public PolicyContext build(EjbJarInfo ejbJar, HashMap<String, BeanContext> deployments) throws OpenEJBException {
+    public PolicyContext build(final EjbJarInfo ejbJar, final HashMap<String, BeanContext> deployments) throws OpenEJBException {
 
-        List<MethodPermissionInfo> normalized = new ArrayList<MethodPermissionInfo>();
+        final List<MethodPermissionInfo> normalized = new ArrayList<MethodPermissionInfo>();
 
         List<MethodPermissionInfo> perms = ejbJar.methodPermissions;
 
-        for (MethodInfo info : ejbJar.excludeList) {
-            MethodPermissionInfo perm = new MethodPermissionInfo();
+        for (final MethodInfo info : ejbJar.excludeList) {
+            final MethodPermissionInfo perm = new MethodPermissionInfo();
             perm.excluded = true;
             perm.methods.add(info);
             perms.add(perm);
@@ -89,28 +91,28 @@ public class JaccPermissionsBuilder {
 
         perms = MethodInfoUtil.normalizeMethodPermissionInfos(perms);
 
-        for (BeanContext beanContext : deployments.values()) {
-            Map<Method, MethodAttributeInfo> attributes = resolveAttributes(perms, beanContext);
+        for (final BeanContext beanContext : deployments.values()) {
+            final Map<Method, MethodAttributeInfo> attributes = resolveAttributes(perms, beanContext);
 
             if (log.isDebugEnabled()) {
-                for (Map.Entry<Method, MethodAttributeInfo> entry : attributes.entrySet()) {
-                    Method method = entry.getKey();
-                    MethodPermissionInfo value = (MethodPermissionInfo) entry.getValue();
+                for (final Map.Entry<Method, MethodAttributeInfo> entry : attributes.entrySet()) {
+                    final Method method = entry.getKey();
+                    final MethodPermissionInfo value = (MethodPermissionInfo) entry.getValue();
                     log.debug("Security Attribute: " + method + " -- " + MethodInfoUtil.toString(value));
                 }
             }
 
-            for (Map.Entry<Method, MethodAttributeInfo> entry : attributes.entrySet()) {
-                Method method = entry.getKey();
+            for (final Map.Entry<Method, MethodAttributeInfo> entry : attributes.entrySet()) {
+                final Method method = entry.getKey();
 
-                MethodPermissionInfo a = (MethodPermissionInfo) entry.getValue();
-                MethodPermissionInfo b = new MethodPermissionInfo();
+                final MethodPermissionInfo a = (MethodPermissionInfo) entry.getValue();
+                final MethodPermissionInfo b = new MethodPermissionInfo();
                 b.excluded = a.excluded;
                 b.unchecked = a.unchecked;
                 b.roleNames.addAll(a.roleNames);
 
-                MethodInfo am = a.methods.get(0);
-                MethodInfo bm = new MethodInfo();
+                final MethodInfo am = a.methods.get(0);
+                final MethodInfo bm = new MethodInfo();
 
                 bm.ejbName = beanContext.getEjbName();
                 bm.ejbDeploymentId = beanContext.getDeploymentID() + "";
@@ -119,7 +121,7 @@ public class JaccPermissionsBuilder {
                 bm.className = method.getDeclaringClass().getName();
                 bm.methodName = method.getName();
                 bm.methodParams = new ArrayList<String>();
-                for (Class<?> type : method.getParameterTypes()) {
+                for (final Class<?> type : method.getParameterTypes()) {
                     bm.methodParams.add(type.getName());
                 }
                 b.methods.add(bm);
@@ -132,19 +134,21 @@ public class JaccPermissionsBuilder {
         ejbJar.methodPermissions.addAll(normalized);
         ejbJar.excludeList.clear();
 
-        PolicyContext policyContext = new PolicyContext(ejbJar.moduleUri.toString());
+        final PolicyContext policyContext = new PolicyContext(ejbJar.moduleUri.toString());
 
-        for (EnterpriseBeanInfo enterpriseBean : ejbJar.enterpriseBeans) {
-            BeanContext beanContext = deployments.get(enterpriseBean.ejbDeploymentId);
+        for (final EnterpriseBeanInfo enterpriseBean : ejbJar.enterpriseBeans) {
+            final BeanContext beanContext = deployments.get(enterpriseBean.ejbDeploymentId);
 
-            PermissionCollection permissions = DelegatePermissionCollection.getPermissionCollection();
+            final PermissionCollection permissions = DelegatePermissionCollection.getPermissionCollection();
 
-            String ejbName = enterpriseBean.ejbName;
+            final String ejbName = enterpriseBean.ejbName;
 
-            for (InterfaceType type : InterfaceType.values()) {
-                if (type == InterfaceType.UNKNOWN) continue;
+            for (final InterfaceType type : InterfaceType.values()) {
+                if (type == InterfaceType.UNKNOWN) {
+                    continue;
+                }
 
-                for (Class interfce : beanContext.getInterfaces(type)) {
+                for (final Class interfce : beanContext.getInterfaces(type)) {
                     addPossibleEjbMethodPermissions(permissions, ejbName, type.getSpecName(), interfce);
                 }
             }
@@ -157,25 +161,29 @@ public class JaccPermissionsBuilder {
         return policyContext;
     }
 
-    private void addDeclaredEjbPermissions(EjbJarInfo ejbJar, EnterpriseBeanInfo beanInfo, String defaultRole, PermissionCollection notAssigned, PolicyContext policyContext) throws OpenEJBException {
+    private void addDeclaredEjbPermissions(final EjbJarInfo ejbJar,
+                                           final EnterpriseBeanInfo beanInfo,
+                                           final String defaultRole,
+                                           PermissionCollection notAssigned,
+                                           final PolicyContext policyContext) throws OpenEJBException {
+
+        final PermissionCollection uncheckedPermissions = policyContext.getUncheckedPermissions();
+        final PermissionCollection excludedPermissions = policyContext.getExcludedPermissions();
+        final Map<String, PermissionCollection> rolePermissions = policyContext.getRolePermissions();
 
-        PermissionCollection uncheckedPermissions = policyContext.getUncheckedPermissions();
-        PermissionCollection excludedPermissions = policyContext.getExcludedPermissions();
-        Map<String, PermissionCollection> rolePermissions = policyContext.getRolePermissions();
-
-        String ejbName = beanInfo.ejbName;
+        final String ejbName = beanInfo.ejbName;
 
         //this can occur in an ear when one ejb module has security and one doesn't.  In this case we still need
         //to make the non-secure one completely unchecked.
         /**
          * JACC v1.0 section 3.1.5.1
          */
-        for (MethodPermissionInfo methodPermission : ejbJar.methodPermissions) {
-            List<String> roleNames = methodPermission.roleNames;
-            boolean unchecked = methodPermission.unchecked;
-            boolean excluded = methodPermission.excluded;
+        for (final MethodPermissionInfo methodPermission : ejbJar.methodPermissions) {
+            final List<String> roleNames = methodPermission.roleNames;
+            final boolean unchecked = methodPermission.unchecked;
+            final boolean excluded = methodPermission.excluded;
 
-            for (MethodInfo method : methodPermission.methods) {
+            for (final MethodInfo method : methodPermission.methods) {
 
                 if (!ejbName.equals(method.ejbName)) {
                     continue;
@@ -189,19 +197,19 @@ public class JaccPermissionsBuilder {
                 }
 
                 // method interface
-                String methodIntf = method.methodIntf;
+                final String methodIntf = method.methodIntf;
 
                 // method parameters
-                String[] methodParams;
+                final String[] methodParams;
                 if (method.methodParams != null) {
-                    List<String> paramList = method.methodParams;
+                    final List<String> paramList = method.methodParams;
                     methodParams = paramList.toArray(new String[paramList.size()]);
                 } else {
                     methodParams = null;
                 }
 
                 // create the permission object
-                EJBMethodPermission permission = new EJBMethodPermission(ejbName, methodName, methodIntf, methodParams);
+                final EJBMethodPermission permission = new EJBMethodPermission(ejbName, methodName, methodIntf, methodParams);
                 notAssigned = cullPermissions(notAssigned, permission);
 
                 // if this is unchecked, mark it as unchecked; otherwise assign the roles
@@ -213,7 +221,7 @@ public class JaccPermissionsBuilder {
                      */
                     excludedPermissions.add(permission);
                 } else {
-                    for (String roleName : roleNames) {
+                    for (final String roleName : roleNames) {
                         PermissionCollection permissions = rolePermissions.get(roleName);
                         if (permissions == null) {
                             permissions = DelegatePermissionCollection.getPermissionCollection();
@@ -229,13 +237,13 @@ public class JaccPermissionsBuilder {
         /**
          * JACC v1.0 section 3.1.5.3
          */
-        for (SecurityRoleReferenceInfo securityRoleRef : beanInfo.securityRoleReferences) {
+        for (final SecurityRoleReferenceInfo securityRoleRef : beanInfo.securityRoleReferences) {
 
             if (securityRoleRef.roleLink == null) {
                 throw new OpenEJBException("Missing role-link");
             }
 
-            String roleLink = securityRoleRef.roleLink;
+            final String roleLink = securityRoleRef.roleLink;
 
             PermissionCollection roleLinks = rolePermissions.get(roleLink);
             if (roleLinks == null) {
@@ -266,9 +274,9 @@ public class JaccPermissionsBuilder {
             }
         }
 
-        Enumeration e = notAssigned.elements();
+        final Enumeration e = notAssigned.elements();
         while (e.hasMoreElements()) {
-            Permission p = (Permission) e.nextElement();
+            final Permission p = (Permission) e.nextElement();
             permissions.add(p);
         }
 
@@ -287,15 +295,18 @@ public class JaccPermissionsBuilder {
      * @param permissions     the permission set to be extended
      * @param ejbName         the name of the EJB
      * @param methodInterface the EJB method interface
-     * @param clazz clazz
-     *
-     * @throws OpenEJBException
-     *          in case a class could not be found
+     * @param clazz           clazz
+     * @throws OpenEJBException in case a class could not be found
      */
-    public void addPossibleEjbMethodPermissions(PermissionCollection permissions, String ejbName, String methodInterface, Class clazz) throws OpenEJBException {
-        if (clazz == null) return;
-        for (Method method : clazz.getMethods()) {
-            String methodIface = "LocalBean".equals(methodInterface) || "LocalBeanHome".equals(methodInterface) ? null : methodInterface;
+    public void addPossibleEjbMethodPermissions(final PermissionCollection permissions,
+                                                final String ejbName,
+                                                final String methodInterface,
+                                                final Class clazz) throws OpenEJBException {
+        if (clazz == null) {
+            return;
+        }
+        for (final Method method : clazz.getMethods()) {
+            final String methodIface = "LocalBean".equals(methodInterface) || "LocalBeanHome".equals(methodInterface) ? null : methodInterface;
             permissions.add(new EJBMethodPermission(ejbName, methodIface, method));
         }
     }
@@ -308,11 +319,11 @@ public class JaccPermissionsBuilder {
      * @param permission  the permission that is to be used for culling
      * @return the culled set of permissions that are not implied by <code>permission</code>
      */
-    private PermissionCollection cullPermissions(PermissionCollection toBeChecked, Permission permission) {
-        PermissionCollection result = DelegatePermissionCollection.getPermissionCollection();
+    private PermissionCollection cullPermissions(final PermissionCollection toBeChecked, final Permission permission) {
+        final PermissionCollection result = DelegatePermissionCollection.getPermissionCollection();
 
-        for (Enumeration e = toBeChecked.elements(); e.hasMoreElements();) {
-            Permission test = (Permission) e.nextElement();
+        for (Enumeration e = toBeChecked.elements(); e.hasMoreElements(); ) {
+            final Permission test = (Permission) e.nextElement();
             if (!permission.implies(test)) {
                 result.add(test);
             }

Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/InitContextFactory.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/InitContextFactory.java?rev=1544204&r1=1544203&r2=1544204&view=diff
==============================================================================
--- tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/InitContextFactory.java (original)
+++ tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/InitContextFactory.java Thu Nov 21 14:57:40 2013
@@ -33,21 +33,24 @@ import java.util.Properties;
 /**
  * @deprecated Use org.apache.openejb.core.LocalInitialContextFactory
  */
+@Deprecated
 public class InitContextFactory implements InitialContextFactory {
 
-    public Context getInitialContext(Hashtable env) throws javax.naming.NamingException {
+    @SuppressWarnings("unchecked")
+    @Override
+    public Context getInitialContext(final Hashtable env) throws javax.naming.NamingException {
         if (!OpenEJB.isInitialized()) {
             initializeOpenEJB(env);
         }
 
-        String user = (String) env.get(Context.SECURITY_PRINCIPAL);
-        String pass = (String) env.get(Context.SECURITY_CREDENTIALS);
-        String realmName = (String) env.get("openejb.authentication.realmName");
+        final String user = (String) env.get(Context.SECURITY_PRINCIPAL);
+        final String pass = (String) env.get(Context.SECURITY_CREDENTIALS);
+        final String realmName = (String) env.get("openejb.authentication.realmName");
 
-        if (user != null && pass != null){
+        if (user != null && pass != null) {
             try {
-                SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
-                Object identity = null;
+                final SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
+                final Object identity;
                 if (realmName == null) {
                     identity = securityService.login(user, pass);
                 } else {
@@ -55,20 +58,21 @@ public class InitContextFactory implemen
                 }
                 securityService.associate(identity);
             } catch (LoginException e) {
-                throw (AuthenticationException) new AuthenticationException("User could not be authenticated: "+user).initCause(e);
+                throw (AuthenticationException) new AuthenticationException("User could not be authenticated: " + user).initCause(e);
             }
         }
 
-        ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
+        final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
         Context context = containerSystem.getJNDIContext();
         context = (Context) context.lookup("openejb/local");
         return context;
 
     }
 
-    private void initializeOpenEJB(Hashtable env) throws javax.naming.NamingException {
+    @SuppressWarnings("UseOfObsoleteCollectionType")
+    private void initializeOpenEJB(final Hashtable env) throws javax.naming.NamingException {
         try {
-            Properties props = new Properties();
+            final Properties props = new Properties();
 
             /* DMB: We should get the defaults from the functionality
             *      Alan is working on.  This is temporary.
@@ -85,11 +89,9 @@ public class InitContextFactory implemen
 
             OpenEJB.init(props);
 
-        }
-        catch (OpenEJBException e) {
+        } catch (OpenEJBException e) {
             throw new NamingException("Cannot initailize OpenEJB", e);
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             throw new NamingException("Cannot initailize OpenEJB", e);
         }
     }

Copied: tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/core/asynch/AsynchInRoleTest.java (from r1544085, tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/core/asynch/AsynchTest.java)
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/core/asynch/AsynchInRoleTest.java?p2=tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/core/asynch/AsynchInRoleTest.java&p1=tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/core/asynch/AsynchTest.java&r1=1544085&r2=1544204&rev=1544204&view=diff
==============================================================================
--- tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/core/asynch/AsynchTest.java (original)
+++ tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/core/asynch/AsynchInRoleTest.java Thu Nov 21 14:57:40 2013
@@ -23,7 +23,7 @@ import org.apache.openejb.assembler.clas
 import org.apache.openejb.config.AppModule;
 import org.apache.openejb.config.ConfigurationFactory;
 import org.apache.openejb.config.EjbModule;
-import org.apache.openejb.core.ivm.naming.InitContextFactory;
+import org.apache.openejb.core.LocalInitialContextFactory;
 import org.apache.openejb.jee.EjbJar;
 import org.apache.openejb.jee.SingletonBean;
 import org.apache.openejb.jee.StatelessBean;
@@ -33,19 +33,21 @@ import org.junit.Before;
 import org.junit.Test;
 
 import javax.annotation.Resource;
+import javax.annotation.security.DeclareRoles;
+import javax.annotation.security.RolesAllowed;
 import javax.ejb.AsyncResult;
 import javax.ejb.Asynchronous;
 import javax.ejb.SessionContext;
 import javax.ejb.Singleton;
 import javax.ejb.Stateless;
 import javax.naming.InitialContext;
+import java.util.Properties;
 import java.util.concurrent.Future;
 
 /**
  * Testing of the @Asynchronous annotation on beans.
- *
  */
-public class AsynchTest{
+public class AsynchInRoleTest {
 
     private Assembler assembler;
 
@@ -53,100 +55,110 @@ public class AsynchTest{
 
     @Before
     public void beforeTest() throws Exception {
-        System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
+        System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
         config = new ConfigurationFactory();
         assembler = new Assembler();
         assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
         assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
     }
 
-	@After
-	public void afterTest() throws Exception{
-	    assembler.destroy();
-	}
-
-	@Test
-	public void testMethodScopeAsynch() throws Exception{
-	    System.out.println(long.class.getName());
-	    System.out.println(String[].class.getCanonicalName());
-	    //Build the application
-	    AppModule app = new AppModule(this.getClass().getClassLoader(), "testasynch");
-        EjbJar ejbJar = new EjbJar();
+    @After
+    public void afterTest() throws Exception {
+        assembler.destroy();
+    }
+
+    @SuppressWarnings("UseOfSystemOutOrSystemErr")
+    @Test
+    public void testMethodScopeAsynch() throws Exception {
+        System.out.println(long.class.getName());
+        System.out.println(String[].class.getCanonicalName());
+        //Build the application
+        final AppModule app = new AppModule(this.getClass().getClassLoader(), "testasynch");
+        final EjbJar ejbJar = new EjbJar();
         ejbJar.addEnterpriseBean(new StatelessBean(TestBeanC.class));
         ejbJar.addEnterpriseBean(new SingletonBean(TestBeanD.class));
         app.getEjbModules().add(new EjbModule(ejbJar));
 
-        AppInfo appInfo = config.configureApplication(app);
+        final AppInfo appInfo = config.configureApplication(app);
         assembler.createApplication(appInfo);
 
-		InitialContext context = new InitialContext();
+        final InitialContext context = new InitialContext();
 
-		String[] beans = new String[]{"TestBeanCLocal", "TestBeanDLocal"};
-		for(String beanName : beans){
-			TestBean testBean = (TestBean)context.lookup(beanName);
-
-			testBean.testA(Thread.currentThread().getId());
-			Thread.sleep(1000L);
-	        Assert.assertEquals("testA was never executed", "testA" , testBean.getLastInvokeMethod());
-	        Future<String> future = testBean.testB(Thread.currentThread().getId());
-			Thread.sleep(1000L);
-			Assert.assertTrue("The task should be done", future.isDone());
-	        Assert.assertEquals("testB was never executed", "testB" , testBean.getLastInvokeMethod());
-	        testBean.testC(Thread.currentThread().getId());
-	        Assert.assertEquals("testC was never executed", "testC" , testBean.getLastInvokeMethod());
-	        testBean.testD(Thread.currentThread().getId());
-	        Assert.assertEquals("testD was never executed", "testD" , testBean.getLastInvokeMethod());
-		}
-	}
-
-	@Test
-	public void testClassScopeAsynch() throws Exception {
-	    //Build the application
-        AppModule app = new AppModule(this.getClass().getClassLoader(), "testclassasynch");
-        EjbJar ejbJar = new EjbJar();
+        final String[] beans = new String[]{"TestBeanCLocal", "TestBeanDLocal"};
+        for (final String beanName : beans) {
+            final TestBean testBean = (TestBean) context.lookup(beanName);
+
+            testBean.testA(Thread.currentThread().getId());
+            Thread.sleep(1000L);
+            Assert.assertEquals("testA was never executed", "testA", testBean.getLastInvokeMethod());
+            final Future<String> future = testBean.testB(Thread.currentThread().getId());
+            Thread.sleep(1000L);
+            Assert.assertTrue("The task should be done", future.isDone());
+            Assert.assertEquals("testB was never executed", "testB", testBean.getLastInvokeMethod());
+            testBean.testC(Thread.currentThread().getId());
+            Assert.assertEquals("testC was never executed", "testC", testBean.getLastInvokeMethod());
+            testBean.testD(Thread.currentThread().getId());
+            Assert.assertEquals("testD was never executed", "testD", testBean.getLastInvokeMethod());
+        }
+    }
+
+    @Test
+    public void testClassScopeAsynch() throws Exception {
+        //Build the application
+        final AppModule app = new AppModule(this.getClass().getClassLoader(), "testclassasynch");
+        final EjbJar ejbJar = new EjbJar();
         ejbJar.addEnterpriseBean(new SingletonBean(TestBeanA.class));
         app.getEjbModules().add(new EjbModule(ejbJar));
 
-        AppInfo appInfo = config.configureApplication(app);
+        final AppInfo appInfo = config.configureApplication(app);
         assembler.createApplication(appInfo);
 
-        InitialContext context = new InitialContext();
-        TestBean test = (TestBean)context.lookup("TestBeanALocal");
+        final Properties env = new Properties();
+        env.put(javax.naming.Context.SECURITY_PRINCIPAL, "jonathan");
+        env.put(javax.naming.Context.SECURITY_CREDENTIALS, "secret");
+
+        final InitialContext context = new InitialContext(env);
+        final TestBean test = (TestBean) context.lookup("TestBeanALocal");
 
         test.testA(Thread.currentThread().getId());
         Thread.sleep(1000L);
-        Assert.assertEquals("testA was never executed", "testA" , test.getLastInvokeMethod());
+        Assert.assertEquals("testA was never executed", "testA", test.getLastInvokeMethod());
 
-        Future<String> future = test.testB(Thread.currentThread().getId());
+        final Future<String> future = test.testB(Thread.currentThread().getId());
         Thread.sleep(1000L);
         Assert.assertTrue("The task should be done", future.isDone());
-        Assert.assertEquals("testB was never executed", "testB" , test.getLastInvokeMethod());
+        Assert.assertEquals("testB was never executed", "testB", test.getLastInvokeMethod());
 
         test.testC(Thread.currentThread().getId());
-        Assert.assertEquals("testC was never executed", "testC" , test.getLastInvokeMethod());
+        Assert.assertEquals("testC was never executed", "testC", test.getLastInvokeMethod());
 
         test.testD(Thread.currentThread().getId());
-        Assert.assertEquals("testD was never executed", "testD" , test.getLastInvokeMethod());
-	}
+        Assert.assertEquals("testD was never executed", "testD", test.getLastInvokeMethod());
+    }
 
     @Test
     public void testSessionContext() throws Exception {
         //Build the application
-        AppModule app = new AppModule(this.getClass().getClassLoader(), "testcanceltask");
-        EjbJar ejbJar = new EjbJar();
+        final AppModule app = new AppModule(this.getClass().getClassLoader(), "testcanceltask");
+        final EjbJar ejbJar = new EjbJar();
         ejbJar.addEnterpriseBean(new StatelessBean(TestBeanB.class));
         app.getEjbModules().add(new EjbModule(ejbJar));
 
-        AppInfo appInfo = config.configureApplication(app);
+        final AppInfo appInfo = config.configureApplication(app);
         assembler.createApplication(appInfo);
 
-        InitialContext context = new InitialContext();
-        TestBean test = (TestBean) context.lookup("TestBeanBLocal");
+        final Properties env = new Properties();
+        env.put(javax.naming.Context.SECURITY_PRINCIPAL, "jonathan");
+        env.put(javax.naming.Context.SECURITY_CREDENTIALS, "secret");
+
+        final InitialContext context = new InitialContext(env);
+
+        final TestBean test = (TestBean) context.lookup("TestBeanBLocal");
 
         test.testA(Thread.currentThread().getId());
         Assert.assertEquals("testA was never executed", "testA", test.getLastInvokeMethod());
 
-        Future<String> future = test.testB(Thread.currentThread().getId());
+        final Future<String> future = test.testB(Thread.currentThread().getId());
         Thread.sleep(1000L);
         Assert.assertFalse(future.cancel(true));
         Assert.assertFalse(future.isCancelled());
@@ -177,68 +189,82 @@ public class AsynchTest{
     }
 
     @Stateless
+    @DeclareRoles({"committer"})
+    @RolesAllowed({"committer"})
     public static class TestBeanC implements TestBean {
 
         private String lastInvokeMethod;
 
+        @Override
         @Asynchronous
-        public void testA(long callerThreadId) {
+        public void testA(final long callerThreadId) {
             Assert.assertFalse("testA should be executed in asynchronous mode", Thread.currentThread().getId() == callerThreadId);
             lastInvokeMethod = "testA";
         }
 
+        @Override
         @Asynchronous
-        public Future<String> testB(long callerThreadId) {
+        public Future<String> testB(final long callerThreadId) {
             Assert.assertFalse("testB should be executed in asynchronous mode", Thread.currentThread().getId() == callerThreadId);
             lastInvokeMethod = "testB";
             return new AsyncResult<String>("testB");
         }
 
-        public Future<String> testC(long callerThreadId) {
+        @Override
+        public Future<String> testC(final long callerThreadId) {
             Assert.assertTrue("testC should be executed in blocing mode", Thread.currentThread().getId() == callerThreadId);
             lastInvokeMethod = "testC";
             return new AsyncResult<String>("testC");
         }
 
-        public void testD(long callerThreadId) {
+        @Override
+        public void testD(final long callerThreadId) {
             Assert.assertTrue("testD should be executed in blocing mode", Thread.currentThread().getId() == callerThreadId);
             lastInvokeMethod = "testD";
         }
 
+        @Override
         public String getLastInvokeMethod() {
             return lastInvokeMethod;
         }
     }
 
     @Singleton
+    @DeclareRoles({"committer"})
+    @RolesAllowed({"committer"})
     public static class TestBeanD implements TestBean {
 
         private String lastInvokeMethod;
 
+        @Override
         @Asynchronous
-        public void testA(long callerThreadId) {
+        public void testA(final long callerThreadId) {
             Assert.assertFalse("testA should be executed in asynchronous mode", Thread.currentThread().getId() == callerThreadId);
             lastInvokeMethod = "testA";
         }
 
+        @Override
         @Asynchronous
-        public Future<String> testB(long callerThreadId) {
+        public Future<String> testB(final long callerThreadId) {
             Assert.assertFalse("testB should be executed in asynchronous mode", Thread.currentThread().getId() == callerThreadId);
             lastInvokeMethod = "testB";
             return new AsyncResult<String>("testB");
         }
 
-        public Future<String> testC(long callerThreadId) {
+        @Override
+        public Future<String> testC(final long callerThreadId) {
             Assert.assertTrue("testC should be executed in blocing mode", Thread.currentThread().getId() == callerThreadId);
             lastInvokeMethod = "testC";
             return new AsyncResult<String>("testC");
         }
 
-        public void testD(long callerThreadId) {
+        @Override
+        public void testD(final long callerThreadId) {
             Assert.assertTrue("testD should be executed in blocing mode", Thread.currentThread().getId() == callerThreadId);
             lastInvokeMethod = "testD";
         }
 
+        @Override
         public String getLastInvokeMethod() {
             return lastInvokeMethod;
         }
@@ -249,12 +275,14 @@ public class AsynchTest{
 
         protected String lastInvokeMethod;
 
-        public void testA(long callerThreadId) {
+        @Override
+        public void testA(final long callerThreadId) {
             Assert.assertFalse("testA should be executed in asynchronous mode", Thread.currentThread().getId() == callerThreadId);
             lastInvokeMethod = "testA";
         }
 
-        public Future<String> testB(long callerThreadId) {
+        @Override
+        public Future<String> testB(final long callerThreadId) {
             Assert.assertFalse("testB should be executed in asynchronous mode", Thread.currentThread().getId() == callerThreadId);
             lastInvokeMethod = "testB";
             return new AsyncResult<String>("testB" + callerThreadId);
@@ -263,25 +291,32 @@ public class AsynchTest{
     }
 
     @Singleton
+    @DeclareRoles({"committer"})
+    @RolesAllowed({"committer"})
     public static class TestBeanA extends AbstractBean implements TestBean {
 
-        public  String getLastInvokeMethod() {
+        @Override
+        public String getLastInvokeMethod() {
             return lastInvokeMethod;
         }
 
-        public Future<String> testC(long callerThreadId) {
+        @Override
+        public Future<String> testC(final long callerThreadId) {
             Assert.assertTrue("testC should be executed in blocing mode", Thread.currentThread().getId() == callerThreadId);
             lastInvokeMethod = "testC";
             return new AsyncResult<String>("testC");
         }
 
-        public void testD(long callerThreadId) {
+        @Override
+        public void testD(final long callerThreadId) {
             Assert.assertTrue("testD should be executed in blocing mode", Thread.currentThread().getId() == callerThreadId);
             lastInvokeMethod = "testD";
         }
     }
 
     @Stateless
+    @DeclareRoles({"committer"})
+    @RolesAllowed({"committer"})
     public static class TestBeanB implements TestBean {
 
         private String lastInvokeMethod;
@@ -289,7 +324,8 @@ public class AsynchTest{
         @Resource
         private SessionContext sessionContext;
 
-        public void testA(long callerThreadId) {
+        @Override
+        public void testA(final long callerThreadId) {
             Assert.assertTrue("testA should be executed in blocing mode", Thread.currentThread().getId() == callerThreadId);
             Exception expectedException = null;
             try {
@@ -301,20 +337,23 @@ public class AsynchTest{
             Assert.assertNotNull("IllegalStateException should be thrown", expectedException);
         }
 
+        @Override
         @Asynchronous
-        public Future<String> testB(long callerThreadId) {
+        public Future<String> testB(final long callerThreadId) {
             Assert.assertFalse("testB should be executed in asynchronous mode", Thread.currentThread().getId() == callerThreadId);
             Assert.assertFalse(sessionContext.wasCancelCalled());
             try {
                 Thread.sleep(3000L);
             } catch (InterruptedException e) {
+                //Ignore
             }
             Assert.assertTrue(sessionContext.wasCancelCalled());
             lastInvokeMethod = "testB";
             return new AsyncResult<String>("echoB");
         }
 
-        public Future<String> testC(long callerThreadId) {
+        @Override
+        public Future<String> testC(final long callerThreadId) {
             Assert.assertTrue("testC should be executed in blocing mode", Thread.currentThread().getId() == callerThreadId);
             Exception expectedException = null;
             try {
@@ -327,8 +366,9 @@ public class AsynchTest{
             return null;
         }
 
+        @Override
         @Asynchronous
-        public void testD(long callerThreadId) {
+        public void testD(final long callerThreadId) {
             Assert.assertFalse("testD should be executed in asynchronous mode", Thread.currentThread().getId() == callerThreadId);
             Exception expectedException = null;
             try {
@@ -340,6 +380,7 @@ public class AsynchTest{
             lastInvokeMethod = "testD";
         }
 
+        @Override
         public String getLastInvokeMethod() {
             return lastInvokeMethod;
         }

Modified: tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/core/asynch/AsynchTest.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/core/asynch/AsynchTest.java?rev=1544204&r1=1544203&r2=1544204&view=diff
==============================================================================
--- tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/core/asynch/AsynchTest.java (original)
+++ tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/core/asynch/AsynchTest.java Thu Nov 21 14:57:40 2013
@@ -23,7 +23,7 @@ import org.apache.openejb.assembler.clas
 import org.apache.openejb.config.AppModule;
 import org.apache.openejb.config.ConfigurationFactory;
 import org.apache.openejb.config.EjbModule;
-import org.apache.openejb.core.ivm.naming.InitContextFactory;
+import org.apache.openejb.core.LocalInitialContextFactory;
 import org.apache.openejb.jee.EjbJar;
 import org.apache.openejb.jee.SingletonBean;
 import org.apache.openejb.jee.StatelessBean;
@@ -53,7 +53,7 @@ public class AsynchTest{
 
     @Before
     public void beforeTest() throws Exception {
-        System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
+        System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
         config = new ConfigurationFactory();
         assembler = new Assembler();
         assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
@@ -65,30 +65,31 @@ public class AsynchTest{
 	    assembler.destroy();
 	}
 
-	@Test
+	@SuppressWarnings("UseOfSystemOutOrSystemErr")
+    @Test
 	public void testMethodScopeAsynch() throws Exception{
 	    System.out.println(long.class.getName());
 	    System.out.println(String[].class.getCanonicalName());
 	    //Build the application
-	    AppModule app = new AppModule(this.getClass().getClassLoader(), "testasynch");
-        EjbJar ejbJar = new EjbJar();
+	    final AppModule app = new AppModule(this.getClass().getClassLoader(), "testasynch");
+        final EjbJar ejbJar = new EjbJar();
         ejbJar.addEnterpriseBean(new StatelessBean(TestBeanC.class));
         ejbJar.addEnterpriseBean(new SingletonBean(TestBeanD.class));
         app.getEjbModules().add(new EjbModule(ejbJar));
 
-        AppInfo appInfo = config.configureApplication(app);
+        final AppInfo appInfo = config.configureApplication(app);
         assembler.createApplication(appInfo);
 
-		InitialContext context = new InitialContext();
+		final InitialContext context = new InitialContext();
 
-		String[] beans = new String[]{"TestBeanCLocal", "TestBeanDLocal"};
-		for(String beanName : beans){
-			TestBean testBean = (TestBean)context.lookup(beanName);
+		final String[] beans = new String[]{"TestBeanCLocal", "TestBeanDLocal"};
+		for(final String beanName : beans){
+			final TestBean testBean = (TestBean)context.lookup(beanName);
 
 			testBean.testA(Thread.currentThread().getId());
 			Thread.sleep(1000L);
 	        Assert.assertEquals("testA was never executed", "testA" , testBean.getLastInvokeMethod());
-	        Future<String> future = testBean.testB(Thread.currentThread().getId());
+	        final Future<String> future = testBean.testB(Thread.currentThread().getId());
 			Thread.sleep(1000L);
 			Assert.assertTrue("The task should be done", future.isDone());
 	        Assert.assertEquals("testB was never executed", "testB" , testBean.getLastInvokeMethod());
@@ -102,22 +103,22 @@ public class AsynchTest{
 	@Test
 	public void testClassScopeAsynch() throws Exception {
 	    //Build the application
-        AppModule app = new AppModule(this.getClass().getClassLoader(), "testclassasynch");
-        EjbJar ejbJar = new EjbJar();
+        final AppModule app = new AppModule(this.getClass().getClassLoader(), "testclassasynch");
+        final EjbJar ejbJar = new EjbJar();
         ejbJar.addEnterpriseBean(new SingletonBean(TestBeanA.class));
         app.getEjbModules().add(new EjbModule(ejbJar));
 
-        AppInfo appInfo = config.configureApplication(app);
+        final AppInfo appInfo = config.configureApplication(app);
         assembler.createApplication(appInfo);
 
-        InitialContext context = new InitialContext();
-        TestBean test = (TestBean)context.lookup("TestBeanALocal");
+        final InitialContext context = new InitialContext();
+        final TestBean test = (TestBean)context.lookup("TestBeanALocal");
 
         test.testA(Thread.currentThread().getId());
         Thread.sleep(1000L);
         Assert.assertEquals("testA was never executed", "testA" , test.getLastInvokeMethod());
 
-        Future<String> future = test.testB(Thread.currentThread().getId());
+        final Future<String> future = test.testB(Thread.currentThread().getId());
         Thread.sleep(1000L);
         Assert.assertTrue("The task should be done", future.isDone());
         Assert.assertEquals("testB was never executed", "testB" , test.getLastInvokeMethod());
@@ -132,21 +133,21 @@ public class AsynchTest{
     @Test
     public void testSessionContext() throws Exception {
         //Build the application
-        AppModule app = new AppModule(this.getClass().getClassLoader(), "testcanceltask");
-        EjbJar ejbJar = new EjbJar();
+        final AppModule app = new AppModule(this.getClass().getClassLoader(), "testcanceltask");
+        final EjbJar ejbJar = new EjbJar();
         ejbJar.addEnterpriseBean(new StatelessBean(TestBeanB.class));
         app.getEjbModules().add(new EjbModule(ejbJar));
 
-        AppInfo appInfo = config.configureApplication(app);
+        final AppInfo appInfo = config.configureApplication(app);
         assembler.createApplication(appInfo);
 
-        InitialContext context = new InitialContext();
-        TestBean test = (TestBean) context.lookup("TestBeanBLocal");
+        final InitialContext context = new InitialContext();
+        final TestBean test = (TestBean) context.lookup("TestBeanBLocal");
 
         test.testA(Thread.currentThread().getId());
         Assert.assertEquals("testA was never executed", "testA", test.getLastInvokeMethod());
 
-        Future<String> future = test.testB(Thread.currentThread().getId());
+        final Future<String> future = test.testB(Thread.currentThread().getId());
         Thread.sleep(1000L);
         Assert.assertFalse(future.cancel(true));
         Assert.assertFalse(future.isCancelled());
@@ -181,30 +182,35 @@ public class AsynchTest{
 
         private String lastInvokeMethod;
 
+        @Override
         @Asynchronous
-        public void testA(long callerThreadId) {
+        public void testA(final long callerThreadId) {
             Assert.assertFalse("testA should be executed in asynchronous mode", Thread.currentThread().getId() == callerThreadId);
             lastInvokeMethod = "testA";
         }
 
+        @Override
         @Asynchronous
-        public Future<String> testB(long callerThreadId) {
+        public Future<String> testB(final long callerThreadId) {
             Assert.assertFalse("testB should be executed in asynchronous mode", Thread.currentThread().getId() == callerThreadId);
             lastInvokeMethod = "testB";
             return new AsyncResult<String>("testB");
         }
 
-        public Future<String> testC(long callerThreadId) {
+        @Override
+        public Future<String> testC(final long callerThreadId) {
             Assert.assertTrue("testC should be executed in blocing mode", Thread.currentThread().getId() == callerThreadId);
             lastInvokeMethod = "testC";
             return new AsyncResult<String>("testC");
         }
 
-        public void testD(long callerThreadId) {
+        @Override
+        public void testD(final long callerThreadId) {
             Assert.assertTrue("testD should be executed in blocing mode", Thread.currentThread().getId() == callerThreadId);
             lastInvokeMethod = "testD";
         }
 
+        @Override
         public String getLastInvokeMethod() {
             return lastInvokeMethod;
         }
@@ -215,30 +221,35 @@ public class AsynchTest{
 
         private String lastInvokeMethod;
 
+        @Override
         @Asynchronous
-        public void testA(long callerThreadId) {
+        public void testA(final long callerThreadId) {
             Assert.assertFalse("testA should be executed in asynchronous mode", Thread.currentThread().getId() == callerThreadId);
             lastInvokeMethod = "testA";
         }
 
+        @Override
         @Asynchronous
-        public Future<String> testB(long callerThreadId) {
+        public Future<String> testB(final long callerThreadId) {
             Assert.assertFalse("testB should be executed in asynchronous mode", Thread.currentThread().getId() == callerThreadId);
             lastInvokeMethod = "testB";
             return new AsyncResult<String>("testB");
         }
 
-        public Future<String> testC(long callerThreadId) {
+        @Override
+        public Future<String> testC(final long callerThreadId) {
             Assert.assertTrue("testC should be executed in blocing mode", Thread.currentThread().getId() == callerThreadId);
             lastInvokeMethod = "testC";
             return new AsyncResult<String>("testC");
         }
 
-        public void testD(long callerThreadId) {
+        @Override
+        public void testD(final long callerThreadId) {
             Assert.assertTrue("testD should be executed in blocing mode", Thread.currentThread().getId() == callerThreadId);
             lastInvokeMethod = "testD";
         }
 
+        @Override
         public String getLastInvokeMethod() {
             return lastInvokeMethod;
         }
@@ -249,12 +260,14 @@ public class AsynchTest{
 
         protected String lastInvokeMethod;
 
-        public void testA(long callerThreadId) {
+        @Override
+        public void testA(final long callerThreadId) {
             Assert.assertFalse("testA should be executed in asynchronous mode", Thread.currentThread().getId() == callerThreadId);
             lastInvokeMethod = "testA";
         }
 
-        public Future<String> testB(long callerThreadId) {
+        @Override
+        public Future<String> testB(final long callerThreadId) {
             Assert.assertFalse("testB should be executed in asynchronous mode", Thread.currentThread().getId() == callerThreadId);
             lastInvokeMethod = "testB";
             return new AsyncResult<String>("testB" + callerThreadId);
@@ -265,17 +278,20 @@ public class AsynchTest{
     @Singleton
     public static class TestBeanA extends AbstractBean implements TestBean {
 
+        @Override
         public  String getLastInvokeMethod() {
             return lastInvokeMethod;
         }
 
-        public Future<String> testC(long callerThreadId) {
+        @Override
+        public Future<String> testC(final long callerThreadId) {
             Assert.assertTrue("testC should be executed in blocing mode", Thread.currentThread().getId() == callerThreadId);
             lastInvokeMethod = "testC";
             return new AsyncResult<String>("testC");
         }
 
-        public void testD(long callerThreadId) {
+        @Override
+        public void testD(final long callerThreadId) {
             Assert.assertTrue("testD should be executed in blocing mode", Thread.currentThread().getId() == callerThreadId);
             lastInvokeMethod = "testD";
         }
@@ -289,7 +305,8 @@ public class AsynchTest{
         @Resource
         private SessionContext sessionContext;
 
-        public void testA(long callerThreadId) {
+        @Override
+        public void testA(final long callerThreadId) {
             Assert.assertTrue("testA should be executed in blocing mode", Thread.currentThread().getId() == callerThreadId);
             Exception expectedException = null;
             try {
@@ -301,20 +318,23 @@ public class AsynchTest{
             Assert.assertNotNull("IllegalStateException should be thrown", expectedException);
         }
 
+        @Override
         @Asynchronous
-        public Future<String> testB(long callerThreadId) {
+        public Future<String> testB(final long callerThreadId) {
             Assert.assertFalse("testB should be executed in asynchronous mode", Thread.currentThread().getId() == callerThreadId);
             Assert.assertFalse(sessionContext.wasCancelCalled());
             try {
                 Thread.sleep(3000L);
             } catch (InterruptedException e) {
+                //Ignore
             }
             Assert.assertTrue(sessionContext.wasCancelCalled());
             lastInvokeMethod = "testB";
             return new AsyncResult<String>("echoB");
         }
 
-        public Future<String> testC(long callerThreadId) {
+        @Override
+        public Future<String> testC(final long callerThreadId) {
             Assert.assertTrue("testC should be executed in blocing mode", Thread.currentThread().getId() == callerThreadId);
             Exception expectedException = null;
             try {
@@ -327,8 +347,9 @@ public class AsynchTest{
             return null;
         }
 
+        @Override
         @Asynchronous
-        public void testD(long callerThreadId) {
+        public void testD(final long callerThreadId) {
             Assert.assertFalse("testD should be executed in asynchronous mode", Thread.currentThread().getId() == callerThreadId);
             Exception expectedException = null;
             try {
@@ -340,6 +361,7 @@ public class AsynchTest{
             lastInvokeMethod = "testD";
         }
 
+        @Override
         public String getLastInvokeMethod() {
             return lastInvokeMethod;
         }

Modified: tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/core/security/ServiceProviderLoginModuleTest.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/core/security/ServiceProviderLoginModuleTest.java?rev=1544204&r1=1544203&r2=1544204&view=diff
==============================================================================
--- tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/core/security/ServiceProviderLoginModuleTest.java (original)
+++ tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/core/security/ServiceProviderLoginModuleTest.java Thu Nov 21 14:57:40 2013
@@ -31,6 +31,7 @@ import static org.apache.openejb.util.UR
 
 public class ServiceProviderLoginModuleTest extends TestCase {
 
+    @Override
     protected void setUp() throws Exception {
         loadJassLoginConfig();
     }
@@ -38,7 +39,7 @@ public class ServiceProviderLoginModuleT
     private static void loadJassLoginConfig() {
         String path = System.getProperty("java.security.auth.login.config");
         if (path == null) {
-            URL resource = ServiceProviderLoginModuleTest.class.getClassLoader().getResource("login.config");
+            final URL resource = ServiceProviderLoginModuleTest.class.getClassLoader().getResource("login.config");
             if (resource != null) {
                 path = toFilePath(resource);
                 System.setProperty("java.security.auth.login.config", path);
@@ -47,10 +48,10 @@ public class ServiceProviderLoginModuleT
     }
 
     public void testLogin() throws LoginException {
-        LoginContext context = new LoginContext("ServiceProviderLogin", new UsernamePasswordCallbackHandler("paul", ""));
+        final LoginContext context = new LoginContext("ServiceProviderLogin", new UsernamePasswordCallbackHandler("paul", ""));
         context.login();
 
-        Subject subject = context.getSubject();
+        final Subject subject = context.getSubject();
 
         assertEquals("Should have three principals", 3, subject.getPrincipals().size());
         assertEquals("Should have one user principal", 1, subject.getPrincipals(UserPrincipal.class).size());
@@ -62,7 +63,7 @@ public class ServiceProviderLoginModuleT
     }
 
     public void testBadUseridLogin() throws Exception {
-        LoginContext context = new LoginContext("ServiceProviderLogin", new UsernamePasswordCallbackHandler("nobody", "secret"));
+        final LoginContext context = new LoginContext("ServiceProviderLogin", new UsernamePasswordCallbackHandler("nobody", "secret"));
         try {
             context.login();
             fail("Should have thrown a FailedLoginException");
@@ -72,7 +73,7 @@ public class ServiceProviderLoginModuleT
     }
 
     public void testBadPWLogin() throws Exception {
-        LoginContext context = new LoginContext("ServiceProviderLogin", new UsernamePasswordCallbackHandler("eddie", "panama"));
+        final LoginContext context = new LoginContext("ServiceProviderLogin", new UsernamePasswordCallbackHandler("eddie", "panama"));
         try {
             context.login();
             fail("Should have thrown a FailedLoginException");

Modified: tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/StatefulTransactionAttributesTest.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/StatefulTransactionAttributesTest.java?rev=1544204&r1=1544203&r2=1544204&view=diff
==============================================================================
--- tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/StatefulTransactionAttributesTest.java (original)
+++ tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/StatefulTransactionAttributesTest.java Thu Nov 21 14:57:40 2013
@@ -56,23 +56,23 @@ public class StatefulTransactionAttribut
     public void test() throws Exception {
         System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
 
-        Assembler assembler = new Assembler();
-        ConfigurationFactory config = new ConfigurationFactory();
+        final Assembler assembler = new Assembler();
+        final ConfigurationFactory config = new ConfigurationFactory();
 
         assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
         assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
         assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
 
-        EjbJar ejbJar = new EjbJar();
+        final EjbJar ejbJar = new EjbJar();
         ejbJar.addEnterpriseBean(new StatefulBean(Color.class));
         ejbJar.addEnterpriseBean(new StatefulBean(Red.class));
         ejbJar.addEnterpriseBean(new StatefulBean(Crimson.class));
         ejbJar.addEnterpriseBean(new StatefulBean(Scarlet.class));
-        List<ContainerTransaction> declared = ejbJar.getAssemblyDescriptor().getContainerTransaction();
+        final List<ContainerTransaction> declared = ejbJar.getAssemblyDescriptor().getContainerTransaction();
 
         declared.add(new ContainerTransaction(TransAttribute.REQUIRED, "*", "Crimson", "*"));
         declared.add(new ContainerTransaction(TransAttribute.REQUIRES_NEW, "*", "Crimson", "create"));
-        ContainerTransaction o = new ContainerTransaction(TransAttribute.SUPPORTS, "*", "Crimson", "create");
+        final ContainerTransaction o = new ContainerTransaction(TransAttribute.SUPPORTS, "*", "Crimson", "create");
         o.getMethod().get(0).setMethodIntf(MethodIntf.HOME);
         declared.add(o);
         declared.add(new ContainerTransaction(TransAttribute.REQUIRES_NEW, "*", "Crimson", "remove"));
@@ -80,13 +80,13 @@ public class StatefulTransactionAttribut
         declared.add(new ContainerTransaction(TransAttribute.NEVER, Red.class.getName(), "Scarlet", "red"));
         declared.add(new ContainerTransaction(TransAttribute.REQUIRED, "Scarlet", Scarlet.class.getMethod("scarlet")));
 
-        EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
+        final EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
         assembler.createApplication(ejbJarInfo);
 
-        InitialContext context = new InitialContext();
+        final InitialContext context = new InitialContext();
 
         {
-            ColorLocal color = (ColorLocal) context.lookup("ColorLocal");
+            final ColorLocal color = (ColorLocal) context.lookup("ColorLocal");
 
             assertEquals("Never", color.color());
             assertEquals("RequiresNew", color.color((Object)null));
@@ -96,7 +96,7 @@ public class StatefulTransactionAttribut
         }
 
         {
-            ColorRemote color = (ColorRemote) context.lookup("ColorRemote");
+            final ColorRemote color = (ColorRemote) context.lookup("ColorRemote");
 
             assertEquals("Never", color.color());
             assertEquals("RequiresNew", color.color((Object)null));
@@ -106,8 +106,8 @@ public class StatefulTransactionAttribut
         }
 
         {
-            ColorEjbLocalHome home = (ColorEjbLocalHome) context.lookup("ColorLocalHome");
-            ColorEjbLocalObject color = home.create("Supports");
+            final ColorEjbLocalHome home = (ColorEjbLocalHome) context.lookup("ColorLocalHome");
+            final ColorEjbLocalObject color = home.create("Supports");
 
             assertEquals("Never", color.color());
             assertEquals("RequiresNew", color.color((Object)null));
@@ -120,8 +120,8 @@ public class StatefulTransactionAttribut
         }
 
         {
-            ColorEjbHome home = (ColorEjbHome) context.lookup("ColorRemoteHome");
-            ColorEjbObject color = home.create("Supports");
+            final ColorEjbHome home = (ColorEjbHome) context.lookup("ColorRemoteHome");
+            final ColorEjbObject color = home.create("Supports");
 
             assertEquals("Never", color.color());
             assertEquals("RequiresNew", color.color((Object)null));
@@ -135,7 +135,7 @@ public class StatefulTransactionAttribut
 
 
         {
-            RedLocal red = (RedLocal) context.lookup("RedLocal");
+            final RedLocal red = (RedLocal) context.lookup("RedLocal");
             assertEquals("Never", red.color());
             assertEquals("Required", red.color((Object)null));
             assertEquals("Supports", red.color((String)null));
@@ -147,7 +147,7 @@ public class StatefulTransactionAttribut
         }
 
         {
-            RedRemote red = (RedRemote) context.lookup("RedRemote");
+            final RedRemote red = (RedRemote) context.lookup("RedRemote");
             assertEquals("Never", red.color());
             assertEquals("Required", red.color((Object)null));
             assertEquals("Supports", red.color((String)null));
@@ -159,8 +159,8 @@ public class StatefulTransactionAttribut
         }
 
         {
-            RedEjbLocalHome home = (RedEjbLocalHome) context.lookup("RedLocalHome");
-            RedEjbLocalObject red = home.create("Supports");
+            final RedEjbLocalHome home = (RedEjbLocalHome) context.lookup("RedLocalHome");
+            final RedEjbLocalObject red = home.create("Supports");
             assertEquals("Never", red.color());
             assertEquals("Required", red.color((Object)null));
             assertEquals("Supports", red.color((String)null));
@@ -175,8 +175,8 @@ public class StatefulTransactionAttribut
         }
 
         {
-            RedEjbHome home = (RedEjbHome) context.lookup("RedRemoteHome");
-            RedEjbObject red = home.create("Supports");
+            final RedEjbHome home = (RedEjbHome) context.lookup("RedRemoteHome");
+            final RedEjbObject red = home.create("Supports");
             assertEquals("Never", red.color());
             assertEquals("Required", red.color((Object)null));
             assertEquals("Supports", red.color((String)null));
@@ -191,7 +191,7 @@ public class StatefulTransactionAttribut
         }
 
         {
-            CrimsonLocal crimson = (CrimsonLocal) context.lookup("CrimsonLocal");
+            final CrimsonLocal crimson = (CrimsonLocal) context.lookup("CrimsonLocal");
             assertEquals("Required", crimson.color());
             assertEquals("Required", crimson.color((Object)null));
             assertEquals("Required", crimson.color((String)null));
@@ -205,7 +205,7 @@ public class StatefulTransactionAttribut
         }
 
         {
-            CrimsonRemote crimson = (CrimsonRemote) context.lookup("CrimsonRemote");
+            final CrimsonRemote crimson = (CrimsonRemote) context.lookup("CrimsonRemote");
             assertEquals("Required", crimson.color());
             assertEquals("Required", crimson.color((Object)null));
             assertEquals("Required", crimson.color((String)null));
@@ -219,8 +219,8 @@ public class StatefulTransactionAttribut
         }
 
         {
-            CrimsonEjbLocalHome home = (CrimsonEjbLocalHome) context.lookup("CrimsonLocalHome");
-            CrimsonEjbLocalObject crimson = home.create("RequiresNew");
+            final CrimsonEjbLocalHome home = (CrimsonEjbLocalHome) context.lookup("CrimsonLocalHome");
+            final CrimsonEjbLocalObject crimson = home.create("RequiresNew");
             assertEquals("Required", crimson.color());
             assertEquals("Required", crimson.color((Object)null));
             assertEquals("Required", crimson.color((String)null));
@@ -236,8 +236,8 @@ public class StatefulTransactionAttribut
         }
 
         {
-            CrimsonEjbHome home = (CrimsonEjbHome) context.lookup("CrimsonRemoteHome");
-            CrimsonEjbObject crimson = home.create("Supports");
+            final CrimsonEjbHome home = (CrimsonEjbHome) context.lookup("CrimsonRemoteHome");
+            final CrimsonEjbObject crimson = home.create("Supports");
             assertEquals("Required", crimson.color());
             assertEquals("Required", crimson.color((Object)null));
             assertEquals("Required", crimson.color((String)null));
@@ -253,7 +253,7 @@ public class StatefulTransactionAttribut
         }
 
         {
-            ScarletLocal scarlet = (ScarletLocal) context.lookup("ScarletLocal");
+            final ScarletLocal scarlet = (ScarletLocal) context.lookup("ScarletLocal");
             assertEquals("Never", scarlet.color());
             assertEquals("Required", scarlet.color((Object)null));
             assertEquals("RequiresNew", scarlet.color((String)null));
@@ -267,7 +267,7 @@ public class StatefulTransactionAttribut
         }
 
         {
-            ScarletRemote scarlet = (ScarletRemote) context.lookup("ScarletRemote");
+            final ScarletRemote scarlet = (ScarletRemote) context.lookup("ScarletRemote");
             assertEquals("Never", scarlet.color());
             assertEquals("Required", scarlet.color((Object)null));
             assertEquals("RequiresNew", scarlet.color((String)null));
@@ -281,8 +281,8 @@ public class StatefulTransactionAttribut
         }
 
         {
-            ScarletEjbLocalHome home = (ScarletEjbLocalHome) context.lookup("ScarletLocalHome");
-            ScarletEjbLocalObject scarlet = home.create("RequiresNew");
+            final ScarletEjbLocalHome home = (ScarletEjbLocalHome) context.lookup("ScarletLocalHome");
+            final ScarletEjbLocalObject scarlet = home.create("RequiresNew");
             assertEquals("Never", scarlet.color());
             assertEquals("Required", scarlet.color((Object)null));
             assertEquals("RequiresNew", scarlet.color((String)null));
@@ -296,8 +296,8 @@ public class StatefulTransactionAttribut
         }
 
         {
-            ScarletEjbHome home = (ScarletEjbHome) context.lookup("ScarletRemoteHome");
-            ScarletEjbObject scarlet = home.create("RequiresNew");
+            final ScarletEjbHome home = (ScarletEjbHome) context.lookup("ScarletRemoteHome");
+            final ScarletEjbObject scarlet = home.create("RequiresNew");
             assertEquals("Never", scarlet.color());
             assertEquals("Required", scarlet.color((Object)null));
             assertEquals("RequiresNew", scarlet.color((String)null));
@@ -320,12 +320,12 @@ public class StatefulTransactionAttribut
     public static class Color implements ColorLocal, ColorRemote {
 
         public String attribute() {
-            ThreadContext context = ThreadContext.getThreadContext();
+            final ThreadContext context = ThreadContext.getThreadContext();
             return context.getTransactionPolicy().toString();
         }
 
         @Init
-        public void ejbCreate(String s){
+        public void ejbCreate(final String s){
             assertEquals(s, attribute());
         }
 
@@ -342,19 +342,19 @@ public class StatefulTransactionAttribut
 
 
         @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
-        public String color(Object o) {
+        public String color(final Object o) {
             return attribute();
         }
 
-        public String color(String s) {
+        public String color(final String s) {
             return attribute();
         }
 
-        public String color(Boolean b) {
+        public String color(final Boolean b) {
             return attribute();
         }
 
-        public String color(Integer i) {
+        public String color(final Integer i) {
             return attribute();
         }
     }
@@ -363,7 +363,7 @@ public class StatefulTransactionAttribut
     @RemoteHome(RedEjbHome.class)
     public static class Red extends Color implements RedLocal, RedRemote {
 
-        public String color(Object o) {
+        public String color(final Object o) {
             return attribute();
         }
 
@@ -372,11 +372,11 @@ public class StatefulTransactionAttribut
             return attribute();
         }
 
-        public String red(Object o) {
+        public String red(final Object o) {
             return attribute();
         }
 
-        public String red(String s) {
+        public String red(final String s) {
             return attribute();
         }
 
@@ -392,7 +392,7 @@ public class StatefulTransactionAttribut
             return attribute();
         }
 
-        public String color(String s) {
+        public String color(final String s) {
             return attribute();
         }
 
@@ -401,7 +401,7 @@ public class StatefulTransactionAttribut
             return attribute();
         }
 
-        public String crimson(String s) {
+        public String crimson(final String s) {
             return attribute();
         }
     }
@@ -416,7 +416,7 @@ public class StatefulTransactionAttribut
             return attribute();
         }
 
-        public String scarlet(String s) {
+        public String scarlet(final String s) {
             return attribute();
         }
     }