[jboss-cvs] JBossAS SVN: r82302 - in projects/ejb3/trunk/testsuite: src/test/java/org/jboss/ejb3/test/ejbthree1624 and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Dec 16 02:05:46 EST 2008
Author: ALRubinger
Date: 2008-12-16 02:05:46 -0500 (Tue, 16 Dec 2008)
New Revision: 82302
Added:
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/AccessManagement.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/CalculatorHome.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/CalculatorLocal.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/CalculatorLocalHome.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/CalculatorRemote.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/CalculatorRemoteBusiness.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/DelegateNotInjectedException.java
Modified:
projects/ejb3/trunk/testsuite/build-test.xml
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/AccessRemoteBusiness.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/CalculatorBean.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
projects/ejb3/trunk/testsuite/src/test/resources/known-issues.xml
Log:
[EJBTHREE-1624] Bulk up Integration Tests for @EJB MC Injection. Fails now due to missing dependency upon the JNDI target.
Modified: projects/ejb3/trunk/testsuite/build-test.xml
===================================================================
--- projects/ejb3/trunk/testsuite/build-test.xml 2008-12-16 07:01:14 UTC (rev 82301)
+++ projects/ejb3/trunk/testsuite/build-test.xml 2008-12-16 07:05:46 UTC (rev 82302)
@@ -2459,8 +2459,8 @@
<build-simple-jar name="ejbthree1504"/>
</target>
- <target name="ejbthree1625">
- <build-simple-jar name="ejbthree1625"/>
+ <target name="ejbthree1624">
+ <build-simple-jar name="ejbthree1624"/>
</target>
<target name="jbas4489"
@@ -4247,7 +4247,7 @@
ejbthree1066, ejbthree1071, ejbthree1075, ejbthree1082, ejbthree1090, ejbthree1092, ejbthree1116, ejbthree1119, ejbthree1122, ejbthree1123, ejbthree1127,
ejbthree1130,
ejbthree1146, ejbthree1148, ejbthree1154, ejbthree1157, ejbthree1222, ejbthree1271, ejbthree1339,
- ejbthree1504, ejbthree1625,
+ ejbthree1504, ejbthree1624,
jaxws, jbas4489, epcpropagation, aspectdomain, ejbcontext, schema, mail, scopedclassloader, dependency,
securitydomain, enventry, security5,
jms/managed, naming, bmt, jca/inflowmdb, pool, jms, security, reference21_30, factory, dd/web, txexceptions,
@@ -5065,7 +5065,7 @@
<param name="test" value="ejbthree1339"/>
</antcall>
<antcall target="test" inheritRefs="true">
- <param name="test" value="ejbthree1625"/>
+ <param name="test" value="ejbthree1624"/>
</antcall>
<antcall target="test" inheritRefs="true">
<param name="test" value="statelesscreation"/>
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-16 07:01:14 UTC (rev 82301)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/AccessBean.java 2008-12-16 07:05:46 UTC (rev 82302)
@@ -22,10 +22,12 @@
package org.jboss.ejb3.test.ejbthree1624;
import javax.ejb.Remote;
-import javax.ejb.Stateless;
+import org.jboss.ejb3.annotation.Service;
+import org.jboss.ejb3.common.registrar.spi.DuplicateBindException;
import org.jboss.ejb3.common.registrar.spi.Ejb3Registrar;
import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
+import org.jboss.ejb3.common.registrar.spi.NotBoundException;
import org.jboss.logging.Logger;
/**
@@ -36,9 +38,9 @@
* @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
* @version $Revision: $
*/
- at Stateless
+ at Service
@Remote(AccessRemoteBusiness.class)
-public class AccessBean implements AccessRemoteBusiness
+public class AccessBean implements AccessRemoteBusiness, AccessManagement
{
// --------------------------------------------------------------------------------||
// Functional Methods -------------------------------------------------------------||
@@ -46,35 +48,111 @@
private static final Logger log = Logger.getLogger(AccessBean.class);
+ private static final String beanBindName = "testMcBean";
+
// --------------------------------------------------------------------------------||
+ // Instance Members ---------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private McBean delegate;
+
+ // --------------------------------------------------------------------------------||
// Required Implementations -------------------------------------------------------||
// --------------------------------------------------------------------------------||
- /* (non-Javadoc)
- * @see org.jboss.ejb3.test.ejbthreexxx.CalculatorBusiness#add(int[])
+ /**
+ * Adds the specified arguments by way of the
+ * local business delegate
+ *
+ * @param args
+ * @return
*/
- public int add(int... args)
+ public int addUsingLocalBusinessView(int... args)
{
+ return delegate.addUsingLocalBusinessView(args);
+ }
+
+ /**
+ * Adds the specified arguments by way of the
+ * remote business delegate
+ *
+ * @param args
+ * @return
+ */
+ public int addUsingRemoteBusinessView(int... args)
+ {
+ return delegate.addUsingRemoteBusinessView(args);
+ }
+
+ /**
+ * Adds the specified arguments by way of the
+ * local component (EJB2.x) delegate
+ *
+ * @param args
+ * @return
+ */
+ public int addUsingLocalComponentView(int... args)
+ {
+ return delegate.addUsingLocalComponentView(args);
+ }
+
+ /**
+ * Adds the specified arguments by way of the
+ * remote component (EJB2.x) delegate
+ *
+ * @param args
+ * @return
+ */
+ public int addUsingRemoteComponentView(int... args)
+ {
+ return delegate.addUsingRemoteComponentView(args);
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Lifecycle Methods --------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Installs the MC Bean Delegate
+ */
+ public void start() throws Exception
+ {
// Initialize
Ejb3Registrar registrar = Ejb3RegistrarLocator.locateRegistrar();
- String beanBindName = "testMcBean";
// Make an POJO and install into MC
McBean bean = new McBean();
- registrar.rebind(beanBindName, bean);
+ try
+ {
+ registrar.bind(beanBindName, bean);
+ }
+ catch (DuplicateBindException e)
+ {
+ throw new RuntimeException("MC Bean already registered under " + beanBindName, e);
+ }
+ log.info("Installed MC Bean delegate " + bean + " at " + beanBindName);
- // Get the POJO from MC
- McBean beanFromMc = registrar.lookup(beanBindName, McBean.class);
+ // Set delegate
+ this.delegate = bean;
+ }
- // Invoke
- int result = beanFromMc.add(1, 2, 3);
- log.debug("Got result from MC Bean: " + result);
-
+ /**
+ * Removes the MC Bean Delegate
+ */
+ public void stop()
+ {
// Unbind MC Bean
- registrar.unbind(beanBindName);
+ try
+ {
+ Ejb3RegistrarLocator.locateRegistrar().unbind(beanBindName);
+ }
+ catch (NotBoundException nbe)
+ {
+ // Ignore
+ }
+ log.info("Removed MC Bean Delegate from " + beanBindName);
- // Return
- return result;
+ // Null out delegate
+ this.delegate = null;
}
-
}
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/AccessManagement.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/AccessManagement.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/AccessManagement.java 2008-12-16 07:05:46 UTC (rev 82302)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.ejbthree1624;
+
+import org.jboss.ejb3.annotation.Management;
+
+/**
+ * AccessManagement
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+ at Management
+public interface AccessManagement
+{
+ void start() throws Exception;
+
+ void stop();
+}
Modified: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/AccessRemoteBusiness.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/AccessRemoteBusiness.java 2008-12-16 07:01:14 UTC (rev 82301)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/AccessRemoteBusiness.java 2008-12-16 07:05:46 UTC (rev 82302)
@@ -27,7 +27,41 @@
* @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
* @version $Revision: $
*/
-public interface AccessRemoteBusiness extends CalculatorService
+public interface AccessRemoteBusiness
{
+ /**
+ * Adds the specified arguments by way of the
+ * local business delegate
+ *
+ * @param args
+ * @return
+ */
+ public int addUsingLocalBusinessView(int... args);
+ /**
+ * Adds the specified arguments by way of the
+ * remote business delegate
+ *
+ * @param args
+ * @return
+ */
+ public int addUsingRemoteBusinessView(int... args);
+
+ /**
+ * Adds the specified arguments by way of the
+ * local component (EJB2.x) delegate
+ *
+ * @param args
+ * @return
+ */
+ public int addUsingLocalComponentView(int... args);
+
+ /**
+ * Adds the specified arguments by way of the
+ * remote component (EJB2.x) delegate
+ *
+ * @param args
+ * @return
+ */
+ public int addUsingRemoteComponentView(int... args);
}
Modified: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/CalculatorBean.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/CalculatorBean.java 2008-12-16 07:01:14 UTC (rev 82301)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/CalculatorBean.java 2008-12-16 07:05:46 UTC (rev 82302)
@@ -22,6 +22,9 @@
package org.jboss.ejb3.test.ejbthree1624;
import javax.ejb.Local;
+import javax.ejb.LocalHome;
+import javax.ejb.Remote;
+import javax.ejb.RemoteHome;
import javax.ejb.Stateless;
/**
@@ -35,7 +38,10 @@
*/
@Stateless
@Local(CalculatorLocalBusiness.class)
-public class CalculatorBean implements CalculatorLocalBusiness
+ at Remote(CalculatorRemoteBusiness.class)
+ at LocalHome(CalculatorLocalHome.class)
+ at RemoteHome(CalculatorHome.class)
+public class CalculatorBean implements CalculatorLocalBusiness, CalculatorRemoteBusiness
{
/* (non-Javadoc)
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/CalculatorHome.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/CalculatorHome.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/CalculatorHome.java 2008-12-16 07:05:46 UTC (rev 82302)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.ejbthree1624;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBHome;
+
+/**
+ * CalculatorHome
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface CalculatorHome extends EJBHome
+{
+ CalculatorRemote create() throws CreateException, RemoteException;
+}
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/CalculatorLocal.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/CalculatorLocal.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/CalculatorLocal.java 2008-12-16 07:05:46 UTC (rev 82302)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.ejbthree1624;
+
+import javax.ejb.EJBLocalObject;
+
+/**
+ * CalculatorLocal
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface CalculatorLocal extends CalculatorService, EJBLocalObject
+{
+
+}
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/CalculatorLocalHome.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/CalculatorLocalHome.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/CalculatorLocalHome.java 2008-12-16 07:05:46 UTC (rev 82302)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.ejbthree1624;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBLocalHome;
+
+/**
+ * CalculatorLocalHome
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface CalculatorLocalHome extends EJBLocalHome
+{
+ CalculatorLocal create() throws CreateException;
+}
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/CalculatorRemote.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/CalculatorRemote.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/CalculatorRemote.java 2008-12-16 07:05:46 UTC (rev 82302)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.ejbthree1624;
+
+import javax.ejb.EJBObject;
+
+/**
+ * CalculatorRemote
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface CalculatorRemote extends CalculatorService, EJBObject
+{
+
+}
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/CalculatorRemoteBusiness.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/CalculatorRemoteBusiness.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/CalculatorRemoteBusiness.java 2008-12-16 07:05:46 UTC (rev 82302)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.ejbthree1624;
+
+/**
+ * CalculatorRemoteBusiness
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface CalculatorRemoteBusiness extends CalculatorService
+{
+
+}
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/DelegateNotInjectedException.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/DelegateNotInjectedException.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/DelegateNotInjectedException.java 2008-12-16 07:05:46 UTC (rev 82302)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.ejbthree1624;
+
+/**
+ * DelegateNotInjectedException
+ *
+ * Thrown in the case an @EJB injection did not occur
+ * into the test MC Bean
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class DelegateNotInjectedException extends IllegalStateException
+{
+
+ private static final long serialVersionUID = 1L;
+
+}
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-16 07:01:14 UTC (rev 82301)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/McBean.java 2008-12-16 07:05:46 UTC (rev 82302)
@@ -21,60 +21,161 @@
*/
package org.jboss.ejb3.test.ejbthree1624;
+import java.rmi.RemoteException;
+
+import javax.ejb.CreateException;
import javax.ejb.EJB;
+import org.jboss.logging.Logger;
+
/**
* McBean
*
* A Simple POJO for testing, to be installed as an MC Bean
*
- * Business methods are delegated to the underlying instance,
- * an EJB which is to be injected
+ * Business methods are delegated to the underlying instances,
+ * EJBs which are to be injected
*
* @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
* @version $Revision: $
*/
public class McBean
{
- /**
- * Injected member
+
+ // --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(McBean.class);
+
+ // --------------------------------------------------------------------------------||
+ // Instance Members ---------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /*
+ * Injected members
*/
//TODO Field member cannot be named the same
// as accessor / mutator methods?
// http://www.jboss.com/index.html?module=bb&op=viewtopic&t=147055
@EJB
- private CalculatorLocalBusiness calc;
+ private CalculatorLocalBusiness calcLocalBusiness;
+ @EJB
+ private CalculatorRemoteBusiness calcRemoteBusiness;
+
+ @EJB
+ private CalculatorLocalHome calcLocalHome;
+
+ @EJB
+ private CalculatorHome calcRemoteHome;
+
+ // --------------------------------------------------------------------------------||
+ // Business Methods ---------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
/**
- * Adds the specified arguments by way of the injected EJB
+ * Adds the specified arguments by way of the
+ * local business delegate
*
* @param args
* @return
*/
- public int add(int... args)
+ public int addUsingLocalBusinessView(int... args)
{
- // Precondition check
- CalculatorLocalBusiness calc = this.getCalculator();
- if (calc == null)
+ // Use the local business delegate
+ log.info("Adding using local business view...");
+ return this.add(calcLocalBusiness, args);
+ }
+
+ /**
+ * Adds the specified arguments by way of the
+ * remote business delegate
+ *
+ * @param args
+ * @return
+ */
+ public int addUsingRemoteBusinessView(int... args)
+ {
+ // Use the remote business delegate
+ log.info("Adding using remote business view...");
+ return this.add(calcRemoteBusiness, args);
+ }
+
+ /**
+ * Adds the specified arguments by way of the
+ * local component (EJB2.x) delegate
+ *
+ * @param args
+ * @return
+ */
+ public int addUsingLocalComponentView(int... args)
+ {
+ // Use the local component delegate via local home
+ log.info("Adding using local component view...");
+ CalculatorLocal local = null;
+ try
{
- throw new RuntimeException("Test fails, EJB instance not injected");
+ local = calcLocalHome.create();
}
-
- // Return the sum
- return calc.add(args);
+ catch (CreateException e)
+ {
+ throw new RuntimeException(e);
+ }
+ return this.add(local, args);
}
- public CalculatorLocalBusiness getCalculator()
+ /**
+ * Adds the specified arguments by way of the
+ * remote component (EJB2.x) delegate
+ *
+ * @param args
+ * @return
+ */
+ public int addUsingRemoteComponentView(int... args)
{
- return calc;
+ // Use the remote component delegate via remote home
+ log.info("Adding using remote component view...");
+ CalculatorRemote remote = null;
+ try
+ {
+ remote = calcRemoteHome.create();
+ }
+ catch (CreateException e)
+ {
+ throw new RuntimeException(e);
+ }
+ catch (RemoteException re)
+ {
+ throw new RuntimeException(re);
+ }
+ return this.add(remote, args);
}
- public void setCalculator(CalculatorLocalBusiness calc)
+ // --------------------------------------------------------------------------------||
+ // Internal Helper Methods --------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Uses the specified delegate to add the specified arguments
+ *
+ * @param delegate
+ * @param args
+ * @return
+ */
+ private int add(CalculatorService delegate, int... args) throws DelegateNotInjectedException
{
- this.calc = calc;
+ // Precondition check
+ if (delegate == null)
+ {
+ throw new DelegateNotInjectedException();
+ }
+
+ // Log
+ log.info("Adding using " + delegate);
+
+ // Return
+ return delegate.add(args);
}
-
-
-
}
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-16 07:01:14 UTC (rev 82301)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1624/unit/Ejb3IntoMcBeanInjectionTestCase.java 2008-12-16 07:05:46 UTC (rev 82302)
@@ -22,6 +22,8 @@
package org.jboss.ejb3.test.ejbthree1624.unit;
import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
import junit.framework.Test;
import junit.framework.TestCase;
@@ -42,6 +44,35 @@
{
// --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * The arguments to be passed along
+ */
+ private static final int[] args =
+ {1, 2, 3, 9};
+
+ /**
+ * The expected result of the tests
+ */
+ private static final int expectedResult;
+ static
+ {
+ int sum = 0;
+ for (int arg : args)
+ {
+ sum += arg;
+ }
+ expectedResult = sum;
+ }
+
+ /**
+ * The hook into the remote container
+ */
+ private static AccessRemoteBusiness accessBean;
+
+ // --------------------------------------------------------------------------------||
// Constructor --------------------------------------------------------------------||
// --------------------------------------------------------------------------------||
@@ -56,7 +87,10 @@
public static Test suite() throws Exception
{
- return getDeploySetup(Ejb3IntoMcBeanInjectionTestCase.class, "ejbthree1625.jar");
+ /*
+ * Get the deploy setup
+ */
+ return getDeploySetup(Ejb3IntoMcBeanInjectionTestCase.class, "ejbthree1624.jar");
}
// --------------------------------------------------------------------------------||
@@ -69,18 +103,69 @@
*/
public void testLocalBusinessInterfaceInjectionIntoMcBean() throws Throwable
{
- // Get the naming context
- Context context = this.getInitialContext();
+ // Test
+ TestCase.assertEquals(expectedResult, getAccessBean().addUsingLocalBusinessView(args));
+ }
- // Get the access bean
- AccessRemoteBusiness access = (AccessRemoteBusiness) context.lookup(AccessBean.class.getSimpleName() + "/remote");
+ /**
+ * Tests that a Remote Business interface can be resolved/injected
+ * into an MC Bean
+ */
+ public void testRemoteBusinessInterfaceInjectionIntoMcBean() throws Throwable
+ {
+ // Test
+ TestCase.assertEquals(expectedResult, getAccessBean().addUsingRemoteBusinessView(args));
+ }
- // Invoke
- int result = access.add(1, 2, 3);
- int expected = 6;
+ /**
+ * Tests that a Local Home interface can be resolved/injected
+ * into an MC Bean
+ */
+ public void testLocalHomeInterfaceInjectionIntoMcBean() throws Throwable
+ {
+ // Test
+ TestCase.assertEquals(expectedResult, getAccessBean().addUsingLocalComponentView(args));
+ }
+ /**
+ * Tests that a Remote Home interface can be resolved/injected
+ * into an MC Bean
+ */
+ public void testRemoteHomeInterfaceInjectionIntoMcBean() throws Throwable
+ {
// Test
- TestCase.assertEquals(expected, result);
+ TestCase.assertEquals(expectedResult, getAccessBean().addUsingRemoteComponentView(args));
}
+ // --------------------------------------------------------------------------------||
+ // Internal Helper Methods --------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Returns the access bean, obtaining from JNDI if necessary
+ */
+ private static synchronized AccessRemoteBusiness getAccessBean()
+ {
+ // If not yet obtained
+ if (accessBean == null)
+ {
+ // Get the naming context
+ Context context = null;
+ try
+ {
+ context = new InitialContext();
+
+ // Get the access bean
+ accessBean = (AccessRemoteBusiness) context.lookup(AccessBean.class.getSimpleName() + "/remote");
+ }
+ catch (NamingException ne)
+ {
+ throw new RuntimeException(ne);
+ }
+ }
+
+ // Return
+ return accessBean;
+ }
+
}
Modified: projects/ejb3/trunk/testsuite/src/test/resources/known-issues.xml
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/resources/known-issues.xml 2008-12-16 07:01:14 UTC (rev 82301)
+++ projects/ejb3/trunk/testsuite/src/test/resources/known-issues.xml 2008-12-16 07:05:46 UTC (rev 82302)
@@ -24,4 +24,16 @@
<!-- EJBTHREE-1222 / EJBTHREE-1621 -->
<entry key="org.jboss.ejb3.test.ejbthree1222.unit.RegularRemoveMethodUnitTestCase.testRemoteNormalMethodNamedRemove">show</entry>
<entry key="org.jboss.ejb3.test.ejbthree1222.unit.RegularRemoveMethodUnitTestCase.testLocalNormalMethodNamedRemove">show</entry>
+ <!-- EJBTHREE-1624 -->
+ <!--
+
+ Just needs a new dependency for the ValueMetaData
+ http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4196761
+
+ -->
+ <entry key="org.jboss.ejb3.test.ejbthree1624.unit.Ejb3IntoMcBeanInjectionTestCase.testLocalBusinessInterfaceInjectionIntoMcBean">show</entry>
+ <entry key="org.jboss.ejb3.test.ejbthree1624.unit.Ejb3IntoMcBeanInjectionTestCase.testRemoteBusinessInterfaceInjectionIntoMcBean">show</entry>
+ <entry key="org.jboss.ejb3.test.ejbthree1624.unit.Ejb3IntoMcBeanInjectionTestCase.testLocalHomeInterfaceInjectionIntoMcBean">show</entry>
+ <entry key="org.jboss.ejb3.test.ejbthree1624.unit.Ejb3IntoMcBeanInjectionTestCase.testRemoteHomeInterfaceInjectionIntoMcBean">show</entry>
+
</properties>
More information about the jboss-cvs-commits
mailing list