[jboss-cvs] JBossAS SVN: r82330 - in projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624: unit and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Dec 16 22:54:44 EST 2008
Author: ALRubinger
Date: 2008-12-16 22:54:44 -0500 (Tue, 16 Dec 2008)
New Revision: 82330
Modified:
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/AccessBean.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/McBean.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/unit/Ejb3IntoMcBeanInjectionTestCase.java
Log:
[EJBTHREE-1624] Make tests fail instead of error for non-injected @EJB in MC Bean
Modified: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/AccessBean.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/AccessBean.java 2008-12-17 01:10:31 UTC (rev 82329)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/AccessBean.java 2008-12-17 03:54:44 UTC (rev 82330)
@@ -122,14 +122,7 @@
// Make an POJO and install into MC
McBean bean = new McBean();
- try
- {
- registrar.bind(beanBindName, bean);
- }
- catch (DuplicateBindException e)
- {
- throw new RuntimeException("MC Bean already registered under " + beanBindName, e);
- }
+ registrar.rebind(beanBindName, bean);
log.info("Installed MC Bean delegate " + bean + " at " + beanBindName);
// Set delegate
Modified: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/McBean.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/McBean.java 2008-12-17 01:10:31 UTC (rev 82329)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/McBean.java 2008-12-17 03:54:44 UTC (rev 82330)
@@ -109,8 +109,14 @@
* @param args
* @return
*/
- public int addUsingLocalComponentView(int... args)
+ public int addUsingLocalComponentView(int... args) throws DelegateNotInjectedException
{
+ // Precondition check
+ if (calcLocalHome == null)
+ {
+ throw new DelegateNotInjectedException();
+ }
+
// Use the local component delegate via local home
log.info("Adding using local component view...");
CalculatorLocal local = null;
@@ -132,8 +138,14 @@
* @param args
* @return
*/
- public int addUsingRemoteComponentView(int... args)
+ public int addUsingRemoteComponentView(int... args) throws DelegateNotInjectedException
{
+ // Precondition check
+ if (calcRemoteHome == null)
+ {
+ throw new DelegateNotInjectedException();
+ }
+
// Use the remote component delegate via remote home
log.info("Adding using remote component view...");
CalculatorRemote remote = null;
Modified: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/unit/Ejb3IntoMcBeanInjectionTestCase.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/unit/Ejb3IntoMcBeanInjectionTestCase.java 2008-12-17 01:10:31 UTC (rev 82329)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/unit/Ejb3IntoMcBeanInjectionTestCase.java 2008-12-17 03:54:44 UTC (rev 82330)
@@ -21,6 +21,7 @@
*/
package org.jboss.ejb3.test.ejbthree1624.unit;
+import javax.ejb.EJBException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
@@ -30,6 +31,7 @@
import org.jboss.ejb3.test.ejbthree1624.AccessBean;
import org.jboss.ejb3.test.ejbthree1624.AccessRemoteBusiness;
+import org.jboss.ejb3.test.ejbthree1624.DelegateNotInjectedException;
import org.jboss.test.JBossTestCase;
/**
@@ -104,7 +106,14 @@
public void testLocalBusinessInterfaceInjectionIntoMcBean() throws Throwable
{
// Test
- TestCase.assertEquals(expectedResult, getAccessBean().addUsingLocalBusinessView(args));
+ try
+ {
+ TestCase.assertEquals(expectedResult, getAccessBean().addUsingLocalBusinessView(args));
+ }
+ catch (EJBException ejbe)
+ {
+ this.checkForFailCaseException(ejbe);
+ }
}
/**
@@ -114,7 +123,14 @@
public void testRemoteBusinessInterfaceInjectionIntoMcBean() throws Throwable
{
// Test
- TestCase.assertEquals(expectedResult, getAccessBean().addUsingRemoteBusinessView(args));
+ try
+ {
+ TestCase.assertEquals(expectedResult, getAccessBean().addUsingRemoteBusinessView(args));
+ }
+ catch (EJBException ejbe)
+ {
+ this.checkForFailCaseException(ejbe);
+ }
}
/**
@@ -124,7 +140,15 @@
public void testLocalHomeInterfaceInjectionIntoMcBean() throws Throwable
{
// Test
- TestCase.assertEquals(expectedResult, getAccessBean().addUsingLocalComponentView(args));
+ try
+ {
+ TestCase.assertEquals(expectedResult, getAccessBean().addUsingLocalComponentView(args));
+
+ }
+ catch (EJBException ejbe)
+ {
+ this.checkForFailCaseException(ejbe);
+ }
}
/**
@@ -134,7 +158,14 @@
public void testRemoteHomeInterfaceInjectionIntoMcBean() throws Throwable
{
// Test
- TestCase.assertEquals(expectedResult, getAccessBean().addUsingRemoteComponentView(args));
+ try
+ {
+ TestCase.assertEquals(expectedResult, getAccessBean().addUsingRemoteComponentView(args));
+ }
+ catch (EJBException ejbe)
+ {
+ this.checkForFailCaseException(ejbe);
+ }
}
// --------------------------------------------------------------------------------||
@@ -142,6 +173,24 @@
// --------------------------------------------------------------------------------||
/**
+ * Fails the test if any execption signaling failure is thrown
+ * (as opposed to erroring out)
+ *
+ * @param ejbe The exception
+ */
+ private void checkForFailCaseException(EJBException ejbe)
+ {
+ if (ejbe.getCause() instanceof DelegateNotInjectedException)
+ {
+ TestCase.fail("Delegate was not injected, caught " + DelegateNotInjectedException.class.getName());
+ }
+ else
+ {
+ throw ejbe;
+ }
+ }
+
+ /**
* Returns the access bean, obtaining from JNDI if necessary
*/
private static synchronized AccessRemoteBusiness getAccessBean()
More information about the jboss-cvs-commits
mailing list