You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by da...@apache.org on 2007/03/06 02:27:07 UTC
svn commit: r514946 - in /incubator/openejb/trunk/openejb3:
container/openejb-core/src/main/java/org/apache/openejb/core/mdb/
itests/openejb-itests-beans/src/main/resources/META-INF/
itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/
Author: dain
Date: Mon Mar 5 17:27:06 2007
New Revision: 514946
URL: http://svn.apache.org/viewvc?view=rev&rev=514946
Log:
Added MDB allowed operation tests
Added:
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/BmtMdbAllowedOperationsTests.java
Removed:
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/BasicMdbTestClient.java
Modified:
incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContext.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/ejb-jar.xml
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/BasicMdbTests.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/MdbAllowedOperationsTests.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/MdbConnectionFactoryTests.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/MdbTestSuite.java
Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContext.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContext.java?view=diff&rev=514946&r1=514945&r2=514946
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContext.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContext.java Mon Mar 5 17:27:06 2007
@@ -149,11 +149,6 @@
}
@Override
- public UserTransaction getUserTransaction(UserTransaction userTransaction) throws IllegalStateException {
- throw new IllegalStateException();
- }
-
- @Override
public boolean getRollbackOnly(TransactionManager transactionManager) throws IllegalStateException {
throw new IllegalStateException();
}
@@ -164,11 +159,6 @@
}
@Override
- public boolean isUserTransactionAccessAllowed() {
- return false;
- }
-
- @Override
public boolean isMessageContextAccessAllowed() {
return false;
}
@@ -204,15 +194,6 @@
throw new IllegalStateException();
}
- @Override
- public UserTransaction getUserTransaction(UserTransaction userTransaction) throws IllegalStateException {
- throw new IllegalStateException();
- }
-
- @Override
- public boolean isUserTransactionAccessAllowed() {
- return false;
- }
}
static {
Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/ejb-jar.xml
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/ejb-jar.xml?view=diff&rev=514946&r1=514945&r2=514946
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/ejb-jar.xml (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/ejb-jar.xml Mon Mar 5 17:27:06 2007
@@ -3596,11 +3596,54 @@
<messaging-type>javax.jms.MessageListener</messaging-type>
<transaction-type>Container</transaction-type>
<message-destination-type>javax.jms.Queue</message-destination-type>
- <message-destination-link>request</message-destination-link>
+ <message-destination-link>BasicMdb</message-destination-link>
<activation-config>
<activation-config-property>
<activation-config-property-name>destination</activation-config-property-name>
- <activation-config-property-value>request</activation-config-property-value>
+ <activation-config-property-value>BasicMdb</activation-config-property-value>
+ </activation-config-property>
+ </activation-config>
+ <resource-ref>
+ <res-ref-name>jms</res-ref-name>
+ <res-type>javax.jms.ConnectionFactory</res-type>
+ <res-auth>Container</res-auth>
+ </resource-ref>
+ <env-entry>
+ <env-entry-name>stateless/references/JNDI_access_to_java_comp_env</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <env-entry-value>Success</env-entry-value>
+ </env-entry>
+ <ejb-ref>
+ <ejb-ref-name>stateless/beanReferences/Enterprise_bean_access</ejb-ref-name>
+ <ejb-ref-type>Session</ejb-ref-type>
+ <home>org.apache.openejb.test.stateful.BasicStatefulHome</home>
+ <remote>org.apache.openejb.test.stateful.BasicStatefulObject</remote>
+ <ejb-link>BasicStatefulBean</ejb-link>
+ </ejb-ref>
+ <resource-ref>
+ <description>
+ This is a reference to a JDBC database.
+ </description>
+ <res-ref-name>stateless/references/Resource_manager_access</res-ref-name>
+ <res-type>javax.sql.DataSource</res-type>
+ <res-auth>Container</res-auth>
+ </resource-ref>
+ </message-driven>
+
+ <message-driven>
+ <description>
+ Blah blah blah . . .
+ </description>
+ <ejb-name>Basic BMT Mdb Bean</ejb-name>
+ <ejb-class>org.apache.openejb.test.mdb.BasicMdbBean</ejb-class>
+ <messaging-type>javax.jms.MessageListener</messaging-type>
+ <transaction-type>Bean</transaction-type>
+ <message-destination-type>javax.jms.Queue</message-destination-type>
+ <message-destination-link>BasicBmtMdb</message-destination-link>
+ <activation-config>
+ <activation-config-property>
+ <activation-config-property-name>destination</activation-config-property-name>
+ <activation-config-property-value>BasicBmtMdb</activation-config-property-value>
</activation-config-property>
</activation-config>
<resource-ref>
Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/BasicMdbTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/BasicMdbTests.java?view=diff&rev=514946&r1=514945&r2=514946
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/BasicMdbTests.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/BasicMdbTests.java Mon Mar 5 17:27:06 2007
@@ -23,12 +23,24 @@
* @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
* @author <a href="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
*/
-public class BasicMdbTests extends BasicMdbTestClient {
+public class BasicMdbTests extends MdbTestClient {
+ protected BasicMdbObject basicMdbObject;
public BasicMdbTests(){
super("BasicMdb.");
}
+ protected void setUp() throws Exception {
+ super.setUp();
+ basicMdbObject = MdbProxy.newProxyInstance(BasicMdbObject.class, connectionFactory, "BasicMdb");
+ }
+
+
+ protected void tearDown() throws Exception {
+ MdbProxy.destroyProxy(basicMdbObject);
+ super.tearDown();
+ }
+
//=================================
// Test remote interface methods
//
@@ -108,8 +120,4 @@
//
// Test remote interface methods
//=================================
-
- protected void tearDown() throws Exception {
- super.tearDown();
- }
}
Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/BmtMdbAllowedOperationsTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/BmtMdbAllowedOperationsTests.java?view=auto&rev=514946
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/BmtMdbAllowedOperationsTests.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/BmtMdbAllowedOperationsTests.java Mon Mar 5 17:27:06 2007
@@ -0,0 +1,216 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.test.mdb;
+
+import org.apache.openejb.test.object.OperationsPolicy;
+
+/**
+ *
+ * [9] Should be run as the nineth test suite of the BasicStatelessTestClients
+ *
+ * <PRE>
+ * =========================================================================
+ * Operations allowed in the methods of a stateless SessionBean with
+ * container-managed transaction demarcation
+ * =========================================================================
+ *
+ * Bean method | Bean method can perform the following operations
+ * ______________________|__________________________________________________
+ * |
+ * constructor | -
+ * ______________________|__________________________________________________
+ * |
+ * setSessionContext | SessionContext methods:
+ * | - getEJBHome
+ * | JNDI access to java:comp/env
+ * ______________________|__________________________________________________
+ * |
+ * ejbCreate | SessionContext methods:
+ * ejbRemove | - getEJBHome
+ * | - getEJBObject
+ * | JNDI access to java:comp/env
+ * ______________________|__________________________________________________
+ * |
+ * business method | SessionContext methods:
+ * from remote interface | - getEJBHome
+ * | - getCallerPrincipal
+ * | - getRollbackOnly
+ * | - isCallerInRole
+ * | - setRollbackOnly
+ * | - getEJBObject
+ * | JNDI access to java:comp/env
+ * | Resource manager access
+ * | Enterprise bean access
+ * ______________________|__________________________________________________
+ * </PRE>
+ *
+ * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
+ * @author <a href="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
+ */
+public class BmtMdbAllowedOperationsTests extends MdbTestClient {
+ protected BasicMdbObject basicMdbObject;
+
+ public BmtMdbAllowedOperationsTests(){
+ super("AllowedOperations.");
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ basicMdbObject = MdbProxy.newProxyInstance(BasicMdbObject.class, connectionFactory, "BasicBmtMdb");
+ basicMdbObject.businessMethod("foo");
+ }
+
+
+ protected void tearDown() throws Exception {
+ MdbProxy.destroyProxy(basicMdbObject);
+ super.tearDown();
+ }
+
+ //=====================================
+ // Test EJBContext allowed operations
+ //
+ /**
+ * <PRE>
+ * Bean method | Bean method can perform the following operations
+ * ______________________|__________________________________________________
+ * |
+ * dependency injection | MessageDrivenContext methods:lookup
+ * methods (e.g., setMes-|
+ * sageDrivenContext) | JNDI access to java:comp/env
+ * ______________________|__________________________________________________
+ * </PRE>
+ */
+ public void test01_setSessionContext(){
+ try {
+ OperationsPolicy policy = new OperationsPolicy();
+ policy.allow( OperationsPolicy.Context_lookup);
+ policy.allow( OperationsPolicy.JNDI_access_to_java_comp_env );
+
+ Object expected = policy;
+ Object actual = basicMdbObject.getAllowedOperationsReport("setMessageDrivenContext");
+
+ assertNotNull("The OperationsPolicy is null", actual );
+ assertEquals( expected, actual );
+ } catch (Exception e){
+ fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ }
+ }
+ /**
+ * <PRE>
+ * Bean method | Bean method can perform the following operations
+ * ______________________|__________________________________________________
+ * |
+ * ejbCreate | SessionContext methods:
+ * ejbRemove | - getEJBHome
+ * | - getEJBObject
+ * | - getUserTransaction,
+ * | JNDI access to java:comp/env
+ * ______________________|__________________________________________________
+ * </PRE>
+ */
+ // todo ejbCreate isn't being called because deployment code is not flagging it as the post construct method
+ public void TODO_test02_ejbCreate() {
+ // The stateless session bean has container managed transactions
+ // so, the test Context_getUserTransaction should fail, but,
+ // it does not. Someone should see why it does not fail.
+ try {
+ OperationsPolicy policy = new OperationsPolicy();
+ policy.allow( OperationsPolicy.Context_getEJBHome );
+ policy.allow( OperationsPolicy.Context_getEJBObject );
+ policy.allow( OperationsPolicy.Context_getUserTransaction );
+ policy.allow( OperationsPolicy.JNDI_access_to_java_comp_env );
+
+ Object expected = policy;
+ Object actual = basicMdbObject.getAllowedOperationsReport("ejbCreate");
+
+ assertNotNull("The OperationsPolicy is null", actual );
+ assertEquals( expected, actual );
+ } catch (Exception e){
+ fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ }
+ }
+ /**
+ * <PRE>
+ * Bean method | Bean method can perform the following operations
+ * ______________________|__________________________________________________
+ * |
+ * ejbCreate | SessionContext methods:
+ * ejbRemove | - getEJBHome
+ * | - getEJBObject
+ * | - getUserTransaction,
+ * | JNDI access to java:comp/env
+ * ______________________|__________________________________________________
+ * </PRE>
+ */
+ public void TODO_test03_ejbRemove(){
+ try {
+ /* TO DO: This test needs unique functionality to work */
+ OperationsPolicy policy = new OperationsPolicy();
+ policy.allow( OperationsPolicy.Context_getEJBHome );
+ policy.allow( OperationsPolicy.Context_getEJBObject );
+ policy.allow( OperationsPolicy.Context_getUserTransaction );
+ policy.allow( OperationsPolicy.JNDI_access_to_java_comp_env );
+
+ Object expected = policy;
+ Object actual = basicMdbObject.getAllowedOperationsReport("ejbRemove");
+
+ assertNotNull("The OperationsPolicy is null", actual );
+ assertEquals( expected, actual );
+ } catch (Exception e){
+ fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ }
+ }
+
+ /**
+ * <PRE>
+ * Bean method | Bean method can perform the following operations
+ * ______________________|__________________________________________________
+ * |
+ * business method | SessionContext methods:
+ * from remote interface | - getCallerPrincipal
+ * | - getUserTransaction,
+ * | - getTimerService
+ * | - lookup
+ * | JNDI access to java:comp/env
+ * | Resource manager access
+ * | Enterprise bean access
+ * | EntityManagerFactory access
+ * ______________________|__________________________________________________
+ * </PRE>
+ */
+ public void test04_businessMethod(){
+ try {
+ OperationsPolicy policy = new OperationsPolicy();
+ policy.allow( OperationsPolicy.Context_getUserTransaction );
+ policy.allow( OperationsPolicy.Context_getCallerPrincipal );
+ policy.allow( OperationsPolicy.Context_lookup );
+ policy.allow( OperationsPolicy.JNDI_access_to_java_comp_env );
+
+ Object expected = policy;
+ Object actual = basicMdbObject.getAllowedOperationsReport("businessMethod");
+
+ assertNotNull("The OperationsPolicy is null", actual );
+ assertEquals( expected, actual );
+ } catch (Exception e){
+ fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ }
+ }
+ //
+ // Test EJBContext allowed operations
+ //=====================================
+}
Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/MdbAllowedOperationsTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/MdbAllowedOperationsTests.java?view=diff&rev=514946&r1=514945&r2=514946
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/MdbAllowedOperationsTests.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/MdbAllowedOperationsTests.java Mon Mar 5 17:27:06 2007
@@ -62,12 +62,23 @@
* @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
* @author <a href="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
*/
-public class MdbAllowedOperationsTests extends BasicMdbTestClient {
+public class MdbAllowedOperationsTests extends MdbTestClient {
+ protected BasicMdbObject basicMdbObject;
public MdbAllowedOperationsTests(){
super("AllowedOperations.");
}
+ protected void setUp() throws Exception {
+ super.setUp();
+ basicMdbObject = MdbProxy.newProxyInstance(BasicMdbObject.class, connectionFactory, "BasicMdb");
+ basicMdbObject.businessMethod("foo");
+ }
+
+ protected void tearDown() throws Exception {
+ MdbProxy.destroyProxy(basicMdbObject);
+ super.tearDown();
+ }
//=====================================
// Test EJBContext allowed operations
@@ -110,7 +121,7 @@
* ______________________|__________________________________________________
* </PRE>
*/
- // todo ejbCreate isn't being called
+ // todo ejbCreate isn't being called because deployment code is not flagging it as the post construct method
public void TODO_test02_ejbCreate() {
// The stateless session bean has container managed transactions
// so, the test Context_getUserTransaction should fail, but,
Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/MdbConnectionFactoryTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/MdbConnectionFactoryTests.java?view=diff&rev=514946&r1=514945&r2=514946
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/MdbConnectionFactoryTests.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/MdbConnectionFactoryTests.java Mon Mar 5 17:27:06 2007
@@ -28,7 +28,7 @@
import java.util.Map;
import java.util.TreeMap;
-public class MdbConnectionFactoryTests extends BasicMdbTestClient {
+public class MdbConnectionFactoryTests extends MdbTestClient {
public MdbConnectionFactoryTests() {
super("ConnectionFactory.");
}
@@ -56,9 +56,8 @@
// initialize session
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Destination requestQueue = session.createQueue("request");
+ Destination requestQueue = session.createQueue("BasicMdb");
Destination responseQueue = session.createTemporaryQueue();
-// Destination responseQueue = session.createQueue("blah");
// Create a request messages
ObjectMessage requestMessage = session.createObjectMessage();
@@ -107,7 +106,12 @@
}
public void test03_proxy() throws Exception {
- String returnValue = basicMdbObject.businessMethod("blah");
- assertEquals("halb", returnValue);
+ BasicMdbObject basicMdbObject = MdbProxy.newProxyInstance(BasicMdbObject.class, connectionFactory, "BasicMdb");
+ try {
+ String returnValue = basicMdbObject.businessMethod("blah");
+ assertEquals("halb", returnValue);
+ } finally {
+ MdbProxy.destroyProxy(basicMdbObject);
+ }
}
}
Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/MdbTestSuite.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/MdbTestSuite.java?view=diff&rev=514946&r1=514945&r2=514946
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/MdbTestSuite.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/MdbTestSuite.java Mon Mar 5 17:27:06 2007
@@ -57,11 +57,15 @@
public static junit.framework.Test suite() {
TestSuite suite = new TestSuite();
+
+ // verify the famework is working
suite.addTest(new MdbConnectionFactoryTests());
suite.addTest(new BasicMdbTests());
+
+ // allowed operations
suite.addTest(new MdbAllowedOperationsTests());
-
-// suite.addTest(new BMTStatelessAllowedOperationsTests());
+ suite.addTest(new BmtMdbAllowedOperationsTests());
+
// suite.addTest(new StatelessBeanTxTests());
// suite.addTest(new StatelessJndiEncTests());
// suite.addTest(new StatelessContextLookupTests());