tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jlaskow...@apache.org
Subject svn commit: r711452 - in /openejb/trunk/openejb3/container/openejb-core/src: main/java/org/apache/openejb/config/rules/ test/java/org/apache/openejb/config/rules/
Date Tue, 04 Nov 2008 22:30:29 GMT
Author: jlaskowski
Date: Tue Nov  4 14:30:28 2008
New Revision: 711452

URL: http://svn.apache.org/viewvc?rev=711452&view=rev
Log:
Fixed some mistakes I made earlier. Hopefully build works fine now (for everybody)

Modified:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/rules/CheckUserTransactionRefs.java
    openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckInjectionTargetsTest.java
    openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckUserTransactionRefsTest.java

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/rules/CheckUserTransactionRefs.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/rules/CheckUserTransactionRefs.java?rev=711452&r1=711451&r2=711452&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/rules/CheckUserTransactionRefs.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/rules/CheckUserTransactionRefs.java
Tue Nov  4 14:30:28 2008
@@ -19,6 +19,7 @@
 import org.apache.openejb.config.EjbModule;
 import org.apache.openejb.jee.EnterpriseBean;
 import org.apache.openejb.jee.ResourceEnvRef;
+import org.apache.openejb.jee.ResourceRef;
 import static org.apache.openejb.jee.TransactionType.CONTAINER;
 
 import java.util.Collection;
@@ -34,15 +35,14 @@
  * @version $Rev$ $Date$
  */
 public class CheckUserTransactionRefs extends ValidationBase {
-    // FIXME: Shouldn't the parent method be protected?
+
     public void validate(EjbModule ejbModule) {
         for (EnterpriseBean bean : ejbModule.getEjbJar().getEnterpriseBeans()) {
             if (bean.getTransactionType() == CONTAINER) {
-                // FIXME: I think bean.getRes should be used instead, but OpenEJB doesn't
allow it atm
-                Collection<ResourceEnvRef> resRefs = bean.getResourceEnvRef();
-                for (ResourceEnvRef resRef : resRefs) {
-                    if ("javax.transaction.UserTransaction".equals(resRef.getResourceEnvRefType()))
{
-                        warn(bean, "userResourceRef.forbiddenForCmtdBeans", resRef.getResourceEnvRefName());
+                Collection<ResourceRef> resRefs = bean.getResourceRef();
+                for (ResourceRef resRef : resRefs) {
+                    if ("javax.transaction.UserTransaction".equals(resRef.getResType()))
{
+                        error(bean, "userResourceRef.forbiddenForCmtdBeans", resRef.getName());
                     }
                 }
             }

Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckInjectionTargetsTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckInjectionTargetsTest.java?rev=711452&r1=711451&r2=711452&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckInjectionTargetsTest.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckInjectionTargetsTest.java
Tue Nov  4 14:30:28 2008
@@ -27,11 +27,12 @@
 import org.apache.openejb.jee.StatelessBean;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.Assert;
 
 /**
  * @version $Rev$ $Date$
  */
-public class CheckInjectionTargetsTest extends TestCase {
+public class CheckInjectionTargetsTest {
 
     private EjbModule module;
     private StatelessBean bean;
@@ -46,9 +47,10 @@
         rule = new CheckInjectionTargets();
         rule.module = module;
     }
-    
-    public void test() {
 
+    @Test
+    public void test() {
+        
         // Valid
         EnvEntry envEntry = new EnvEntry("count", Integer.class.getName(), "10");
         envEntry.getInjectionTarget().add(new InjectionTarget("org.acme.CheeseEjb", "org.acme.CheeseEjb/count"));
@@ -67,23 +69,7 @@
         rule.validate(module);
 
         ValidationWarning[] warnings = module.getValidation().getWarnings();
-        assertEquals(warnings.length, 2);
+        Assert.assertEquals(warnings.length, 2);
 
     }
-    
-    @Test
-    public void testUserTransaction() {
-        // 16.12 UserTransaction Interface
-        // only session and message-driven beans with bean-managed transaction demarcation
are allowed to use this interface
-        ResourceEnvRef resEnvEntry = new ResourceEnvRef("jta/UserTransaction", "javax.transaction.UserTransaction");
-        bean.getResourceEnvRef().add(resEnvEntry);
-        
-        rule.validate(module);
-
-        ValidationError[] errors = module.getValidation().getErrors();
-        assertEquals(errors.length, 1);
-
-        // The authenticationType and shareable elements of the Resource annotation must
not be specified
-    }
-
 }

Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckUserTransactionRefsTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckUserTransactionRefsTest.java?rev=711452&r1=711451&r2=711452&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckUserTransactionRefsTest.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckUserTransactionRefsTest.java
Tue Nov  4 14:30:28 2008
@@ -16,13 +16,15 @@
  */
 package org.apache.openejb.config.rules;
 
-import org.apache.openejb.config.AppModule;
 import org.apache.openejb.config.EjbModule;
 import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.InjectionTarget;
 import org.apache.openejb.jee.ResourceRef;
 import org.apache.openejb.jee.StatelessBean;
 import static org.apache.openejb.jee.TransactionType.CONTAINER;
+import static org.hamcrest.CoreMatchers.is;
 import org.junit.After;
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -31,44 +33,42 @@
  */
 public class CheckUserTransactionRefsTest {
 
-    AppModule appModule;
+    private EjbModule module;
+    private StatelessBean bean;
 
-    @Before
-    public void setUp() {
-        // Stateless session bean with container-managed transaction demarcation
-        StatelessBean cmtdSlsb = new StatelessBean("CheckUserTransactionRefsTest", "nopackage.CheckUserTransactionRefsTestBean");
-        cmtdSlsb.setTransactionType(CONTAINER);
-
-        // "@Resource UserTransaction tx" declaration
-        ResourceRef resourceRef = new ResourceRef();
-        resourceRef.setName("nopackage.CheckUserTransactionRefsTestBean/tx");
-        resourceRef.setResType("javax.transaction.UserTransaction");
-
-        cmtdSlsb.getResourceRef().add(resourceRef);
+    private CheckUserTransactionRefs rule;
 
-        EjbJar ejbJar = new EjbJar();
-        ejbJar.addEnterpriseBean(cmtdSlsb);
-        EjbModule ejbModule = new EjbModule(ejbJar);
+    @Before
+    public void initialize() {
+        bean = new StatelessBean("CheeseEjb", "org.acme.CheeseEjb");
+        bean.setTransactionType(CONTAINER);
 
-        appModule = new AppModule(getClass().getClassLoader(), "some/path");
-        appModule.getEjbModules().add(ejbModule);
+        module = new EjbModule(new EjbJar());
+        module.getEjbJar().addEnterpriseBean(bean);
 
+        rule = new CheckUserTransactionRefs();
+        rule.module = module;
     }
 
     @Test
     public void testSLSBwithUserTransaction() {
 
-        CheckUserTransactionRefs checkUserTransactionRefs = new CheckUserTransactionRefs();
-        // FIXME: It's not possible to run validate(ejbModule) with warn without setting
up module in the validate first
-        checkUserTransactionRefs.validate(appModule);
-
-        assert appModule.getValidation().getErrors().length == 0;
-        assert appModule.getValidation().getWarnings().length == 1;
-        assert appModule.getValidation().getFailures().length == 0;
+        // "@Resource UserTransaction tx" declaration
+        ResourceRef resourceRef = new ResourceRef();
+        resourceRef.setResRefName("org.acme.CheeseEjb/tx");
+        resourceRef.setResType("javax.transaction.UserTransaction");
+        resourceRef.getInjectionTarget().add(new InjectionTarget("org.acme.CheeseEjb", "org.acme.CheeseEjb/tx"));
+        bean.getResourceRef().add(resourceRef);
+
+        rule.validate(module);
+
+        Assert.assertThat(module.getValidation().getErrors().length, is(1));
+        Assert.assertThat(module.getValidation().getWarnings().length, is(0));
+        Assert.assertThat(module.getValidation().getFailures().length, is(0));
     }
 
     @After
     public void cleanUp() {
-        appModule = null;
+        module = null;
     }
 }



Mime
View raw message