[jboss-cvs] JBossAS SVN: r88371 - in projects/ejb3/trunk/testsuite: src/test/java/org/jboss/ejb3/test and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu May 7 12:05:36 EDT 2009
Author: ALRubinger
Date: 2009-05-07 12:05:36 -0400 (Thu, 07 May 2009)
New Revision: 88371
Added:
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1786/
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1786/EndpointAccessBean.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1786/EndpointAccessRemoteBusiness.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1786/StatefulBean.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1786/StatefulCommonBusiness.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1786/StatefulLocalBusiness.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1786/StatefulRemoteBusiness.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1786/unit/
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1786/unit/EndpointTestCase.java
Modified:
projects/ejb3/trunk/testsuite/build-test.xml
projects/ejb3/trunk/testsuite/pom.xml
Log:
[EJBTHREE-1786] Added tests for Endpoint API
Modified: projects/ejb3/trunk/testsuite/build-test.xml
===================================================================
--- projects/ejb3/trunk/testsuite/build-test.xml 2009-05-07 15:57:49 UTC (rev 88370)
+++ projects/ejb3/trunk/testsuite/build-test.xml 2009-05-07 16:05:36 UTC (rev 88371)
@@ -4290,13 +4290,16 @@
<include name="META-INF/*.xml"/>
</fileset>
</jar>
- </target>
+ </target>
- <target name="ejbthree1807">
- <build-simple-jar name="ejbthree1807"/>
- </target>
+ <target name="ejbthree1786">
+ <build-simple-jar name="ejbthree1786"/>
+ </target>
+
+ <target name="ejbthree1807">
+ <build-simple-jar name="ejbthree1807"/>
+ </target>
-
<target name="jars" depends="statefulproxyfactoryoverride, removedislocal, statelesscreation, defaultremotebindings, localfromremote, clusteredjms, entityoptimisticlocking, concurrentnaming, propertyreplacement, persistenceunits, appclient, tck5sec, invalidtxmdb, descriptortypo, libdeployment, homeinterface, arjuna, mdbtransactions, unauthenticatedprincipal, clusteredservice, invoker, classloader,
concurrent,
circulardependency, jsp, timerdependency, servicedependency, stateless14, webservices, ear, ejbthree440,
@@ -4313,7 +4316,7 @@
ejbthree1040,
ejbthree1057, ejbthree1059, ejbthree1060,
ejbthree1062,
- ejbthree1066, ejbthree1071, ejbthree1075, ejbthree1082, ejbthree1090, ejbthree1092, ejbthree1116, ejbthree1119, ejbthree1122, ejbthree1123, ejbthree1127,
+ ejbthree1066, ejbthree1071, ejbthree1075, ejbthree1786, ejbthree1082, ejbthree1090, ejbthree1092, ejbthree1116, ejbthree1119, ejbthree1122, ejbthree1123, ejbthree1127,
ejbthree1130,
ejbthree1146, ejbthree1148, ejbthree1154, ejbthree1157, ejbthree1222, ejbthree1271, ejbthree1339,
ejbthree1504, ejbthree1530, ejbthree1624, ejbthree1647,
@@ -5088,6 +5091,9 @@
<antcall target="test" inheritRefs="true">
<param name="test" value="ejbthree1075"/>
</antcall>
+ <antcall target="test" inheritRefs="true">
+ <param name="test" value="ejbthree1786"/>
+ </antcall>
<antcall target="test" inheritRefs="true">
<param name="test" value="ejbthree1082"/>
</antcall>
Modified: projects/ejb3/trunk/testsuite/pom.xml
===================================================================
--- projects/ejb3/trunk/testsuite/pom.xml 2009-05-07 15:57:49 UTC (rev 88370)
+++ projects/ejb3/trunk/testsuite/pom.xml 2009-05-07 16:05:36 UTC (rev 88371)
@@ -226,6 +226,20 @@
<dependency>
<groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-endpoint</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-endpoint-deployer</artifactId>
+ <version>0.1.1-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
<artifactId>jboss-ejb3-pool</artifactId>
<version>0.13.0-SNAPSHOT</version>
<scope>test</scope>
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1786/EndpointAccessBean.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1786/EndpointAccessBean.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1786/EndpointAccessBean.java 2009-05-07 16:05:36 UTC (rev 88371)
@@ -0,0 +1,205 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.ejbthree1786;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.util.Set;
+
+import javax.annotation.PostConstruct;
+import javax.ejb.EJB;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.ejb3.common.deployers.spi.Ejb3DeployerUtils;
+import org.jboss.ejb3.common.registrar.spi.Ejb3Registrar;
+import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
+import org.jboss.ejb3.endpoint.Endpoint;
+import org.jboss.ejb3.endpoint.SessionFactory;
+import org.jboss.ejb3.endpoint.deployers.EndpointResolver;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+
+/**
+ * EndpointAccessBean
+ *
+ * A test SLSB which delegates to an {@link Endpoint}
+ * and exposes a remote view of Endpoint operations upon a test SFSB
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+ at Stateless
+ at Remote(EndpointAccessRemoteBusiness.class)
+ at RemoteBinding(jndiBinding = EndpointAccessRemoteBusiness.JNDI_NAME)
+public class EndpointAccessBean implements EndpointAccessRemoteBusiness, Endpoint
+{
+
+ //------------------------------------------------------------------------||
+ // Class Members ---------------------------------------------------------||
+ //------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(EndpointAccessBean.class);
+
+ /**
+ * @deprecated EJBIdentifyier should be injected, but there's no hook to MC here
+ */
+ @Deprecated
+ private static final String MC_BIND_NAME_ENDPOINT_RESOLVER = "EJB3EndpointResolver";
+
+ private static final String EJB_NAME_TEST_SFSB = StatefulBean.class.getSimpleName();
+
+ //------------------------------------------------------------------------||
+ // Instance Members ------------------------------------------------------||
+ //------------------------------------------------------------------------||
+
+ /**
+ * The underlying endpoint
+ */
+ private Endpoint endpoint;
+
+ private EndpointResolver resolver;
+
+ /**
+ * For the dependency only
+ */
+ @EJB
+ @SuppressWarnings("unused")
+ private StatefulLocalBusiness dependency;
+
+ //------------------------------------------------------------------------||
+ // Lifecycle -------------------------------------------------------------||
+ //------------------------------------------------------------------------||
+ /**
+ * Obtains the endpoint from MC
+ */
+ @PostConstruct
+ public void initialize() throws Exception
+ {
+ // Get the registrar (hook to MC)
+ @Deprecated
+ Ejb3Registrar registrar = Ejb3RegistrarLocator.locateRegistrar();
+
+ // Get the resolver
+ //TODO Inject instead of lookup
+ resolver = registrar.lookup(MC_BIND_NAME_ENDPOINT_RESOLVER, EndpointResolver.class);
+ log.info("Got " + EndpointResolver.class.getSimpleName() + ": " + resolver);
+
+ // Hack to get at the DU
+ // Get the Container
+ final Set<DeploymentUnit> allDeployments = Ejb3DeployerUtils.getAllEjb3DeploymentUnitsInMainDeployer();
+ final String targetEjbName = EJB_NAME_TEST_SFSB;
+ DeploymentUnit testSfsfDu = null;
+ if (allDeployments != null)
+ {
+ for (DeploymentUnit du : allDeployments)
+ {
+ // Get out the EJB3 metadata
+ final JBossMetaData metadata = du.getAttachment(JBossMetaData.class);
+ if (metadata == null || !metadata.isEJB3x())
+ {
+ // Keep looking
+ continue;
+ }
+
+ // Look for the EJB by name
+ log.info("Querying " + DeploymentUnit.class.getSimpleName() + ": " + du + " for EJB of name "
+ + targetEjbName);
+ if (metadata.getEnterpriseBean(targetEjbName) != null)
+ {
+ testSfsfDu = du;
+ log.info("Got " + DeploymentUnit.class.getSimpleName() + ": " + testSfsfDu);
+ break;
+ }
+ }
+ }
+ if (testSfsfDu == null)
+ {
+ throw new RuntimeException("Could not locate the test SFSB Deployment unit containing EJB with name: "
+ + targetEjbName);
+ }
+
+ // Get the endpoint
+ final String endpointMcBindName = resolver.resolve(testSfsfDu, EJB_NAME_TEST_SFSB);
+
+ // Real usage will inject instead of lookup
+ endpoint = registrar.lookup(endpointMcBindName, Endpoint.class);
+ log.info("Got " + Endpoint.class.getSimpleName() + ": " + endpoint);
+
+ }
+
+ //------------------------------------------------------------------------||
+ // Required Implementations ----------------------------------------------||
+ //------------------------------------------------------------------------||
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.endpoint.Endpoint#getSessionFactory()
+ */
+ public SessionFactory getSessionFactory() throws IllegalStateException
+ {
+ // TODO Auto-generated method stub
+ return endpoint.getSessionFactory();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.endpoint.Endpoint#invoke(java.io.Serializable, java.lang.Class, java.lang.reflect.Method, java.lang.Object[])
+ */
+ public Object invoke(Serializable session, Class<?> invokedBusinessInterface, Method method, Object[] args)
+ throws Throwable
+ {
+ log.info("invoking: " + invokedBusinessInterface + "");
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.endpoint.Endpoint#isSessionAware()
+ */
+ public boolean isSessionAware()
+ {
+ log.info("Invoked isSessionAware");
+ return endpoint.isSessionAware();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.test.ejbthree1786.EndpointAccessRemoteBusiness#createSession()
+ */
+ public Serializable createSession()
+ {
+ log.info("Attempting to create session...");
+ Serializable id = endpoint.getSessionFactory().createSession(null, null);
+ log.info("Created session with ID: " + id);
+ return id;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.test.ejbthree1786.EndpointAccessRemoteBusiness#destroySession(java.io.Serializable)
+ */
+ public void destroySession(Serializable id)
+ {
+ log.info("Attempting to destroy session with ID: " + id);
+ endpoint.getSessionFactory().destroySession(id);
+ log.info("Session with ID: " + id + " destroyed.");
+ }
+
+}
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1786/EndpointAccessRemoteBusiness.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1786/EndpointAccessRemoteBusiness.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1786/EndpointAccessRemoteBusiness.java 2009-05-07 16:05:36 UTC (rev 88371)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.ejbthree1786;
+
+import java.io.Serializable;
+
+/**
+ * EndpointAccessRemoteBusiness
+ *
+ * A test remote business interface which provides
+ * access to the Endpoint, for invocations upon the container
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface EndpointAccessRemoteBusiness
+{
+ //------------------------------------------------------------------------||
+ // Constants -------------------------------------------------------------||
+ //------------------------------------------------------------------------||
+
+ String JNDI_NAME = "EndpointAccessRemoteBusiness";
+
+ //------------------------------------------------------------------------||
+ // Contracts -------------------------------------------------------------||
+ //------------------------------------------------------------------------||
+
+ /**
+ * Creates new session
+ *
+ * @return The new Session ID
+ */
+ Serializable createSession();
+
+ /**
+ * Destroys the specified session
+ *
+ * @param id
+ */
+ void destroySession(Serializable id);
+}
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1786/StatefulBean.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1786/StatefulBean.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1786/StatefulBean.java 2009-05-07 16:05:36 UTC (rev 88371)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.ejbthree1786;
+
+import javax.ejb.Local;
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+
+import org.jboss.ejb3.annotation.RemoteBinding;
+
+/**
+ * StatefulBean
+ *
+ * A test SFSB which provides access to an internal counter
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+ at Stateful
+ at Local(StatefulLocalBusiness.class)
+ at Remote(StatefulRemoteBusiness.class)
+ at RemoteBinding(jndiBinding = StatefulRemoteBusiness.JNDI_NAME)
+public class StatefulBean implements StatefulCommonBusiness
+{
+
+ //------------------------------------------------------------------------||
+ // Instance Members ------------------------------------------------------||
+ //------------------------------------------------------------------------||
+
+ /**
+ * The internal counter
+ */
+ private int counter;
+
+ //------------------------------------------------------------------------||
+ // Required Implementations ----------------------------------------------||
+ //------------------------------------------------------------------------||
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.test.ejbthree1786.StatefulRemoteBusiness#getCounter()
+ */
+ public int getCounter()
+ {
+ return counter;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.test.ejbthree1786.StatefulRemoteBusiness#incrementCounter()
+ */
+ public void incrementCounter()
+ {
+ counter++;
+ }
+
+}
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1786/StatefulCommonBusiness.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1786/StatefulCommonBusiness.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1786/StatefulCommonBusiness.java 2009-05-07 16:05:36 UTC (rev 88371)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.ejbthree1786;
+
+/**
+ * StatefulLocalBusiness
+ *
+ * A test SFSB business interface
+ * which maintains an internal counter
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface StatefulCommonBusiness
+{
+
+ //------------------------------------------------------------------------||
+ // Contracts -------------------------------------------------------------||
+ //------------------------------------------------------------------------||
+
+ /**
+ * Obtains the value of the internal counter
+ */
+ int getCounter();
+
+ /**
+ * Increments the internal counter
+ */
+ void incrementCounter();
+}
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1786/StatefulLocalBusiness.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1786/StatefulLocalBusiness.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1786/StatefulLocalBusiness.java 2009-05-07 16:05:36 UTC (rev 88371)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.ejbthree1786;
+
+/**
+ * StatefulLocalBusiness
+ *
+ * A test SFSB local business interface
+ * which maintains an internal counter
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface StatefulLocalBusiness extends StatefulCommonBusiness
+{
+
+}
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1786/StatefulRemoteBusiness.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1786/StatefulRemoteBusiness.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1786/StatefulRemoteBusiness.java 2009-05-07 16:05:36 UTC (rev 88371)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.ejbthree1786;
+
+/**
+ * StatefulRemoteBusiness
+ *
+ * A test SFSB remote business interface
+ * which maintains an internal counter
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface StatefulRemoteBusiness extends StatefulCommonBusiness
+{
+ //------------------------------------------------------------------------||
+ // Constants -------------------------------------------------------------||
+ //------------------------------------------------------------------------||
+
+ String JNDI_NAME = "StatefulRemoteBusiness";
+}
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1786/unit/EndpointTestCase.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1786/unit/EndpointTestCase.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1786/unit/EndpointTestCase.java 2009-05-07 16:05:36 UTC (rev 88371)
@@ -0,0 +1,172 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.ejbthree1786.unit;
+
+import java.io.Serializable;
+import java.lang.reflect.Proxy;
+
+import javax.ejb.NoSuchEJBException;
+import javax.naming.Context;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+
+import org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandler;
+import org.jboss.ejb3.test.ejbthree1786.EndpointAccessRemoteBusiness;
+import org.jboss.ejb3.test.ejbthree1786.StatefulRemoteBusiness;
+import org.jboss.logging.Logger;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * EndpointTestCase
+ *
+ * Test Cases to ensure that the Endpoint API is working as expected
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class EndpointTestCase extends JBossTestCase
+{
+ //------------------------------------------------------------------------||
+ // Class Members ---------------------------------------------------------||
+ //------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(EndpointTestCase.class);
+
+ //------------------------------------------------------------------------||
+ // Instance Members ------------------------------------------------------||
+ //------------------------------------------------------------------------||
+
+ /**
+ * The EJB used to hook into the endpoint
+ */
+ private EndpointAccessRemoteBusiness endpointAccessBean;
+
+ //------------------------------------------------------------------------||
+ // Constructor -----------------------------------------------------------||
+ //------------------------------------------------------------------------||
+
+ public EndpointTestCase()
+ {
+ super(EndpointTestCase.class.getName());
+ }
+
+ //------------------------------------------------------------------------||
+ // Suite -----------------------------------------------------------------||
+ //------------------------------------------------------------------------||
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(EndpointTestCase.class, "ejbthree1786.jar");
+ }
+
+ //------------------------------------------------------------------------||
+ // Tests -----------------------------------------------------------------||
+ //------------------------------------------------------------------------||
+
+ /**
+ * Tests that we may create/destroy a session
+ */
+
+ public void testRemoteSfsb() throws Throwable
+ {
+ // Log
+ log.info("testRemoteSfsb");
+
+ // Create a new Session
+ final StatefulRemoteBusiness sfsb = this.getSfsb();
+ log.info("Got SFSB: " + sfsb);
+
+ // Test state
+ int i = 0;
+ int counter = sfsb.getCounter();
+ TestCase.assertEquals(i++, counter);
+ log.info("First counter check as expected");
+
+ // Invoke to increment the counter, and test
+ sfsb.incrementCounter();
+ counter = sfsb.getCounter();
+ TestCase.assertEquals(i++, counter);
+ log.info("Increment, then counter check as expected");
+
+ /*
+ * Try a backdoor removal through the endpoint
+ */
+
+ // Get the endpoint access EJB
+ final EndpointAccessRemoteBusiness endpointAccess = this.getEndpointAccessBean();
+ log.info("Got endpoint access bean: " + endpointAccess);
+
+ // Get the ID of the SFSB
+ final SessionProxyInvocationHandler handler = (SessionProxyInvocationHandler) Proxy.getInvocationHandler(sfsb);
+ final Serializable id = (Serializable) handler.getTarget();
+
+ // Remove
+ endpointAccess.destroySession(id);
+
+ // Ensure Removed
+ boolean removed = false;
+ try
+ {
+ sfsb.getCounter();
+ }
+ catch (final NoSuchEJBException nsee)
+ {
+ removed = true;
+ }
+ TestCase.assertTrue("The test SFSB was not removed", removed);
+
+ }
+
+ //------------------------------------------------------------------------||
+ // Internal Helper Methods -----------------------------------------------||
+ //------------------------------------------------------------------------||
+
+ /**
+ * Obtains the EJB via which we'll access the endpoint
+ */
+ private EndpointAccessRemoteBusiness getEndpointAccessBean() throws Throwable
+ {
+ // If we haven't yet getten the bean
+ if (endpointAccessBean == null)
+ {
+ // Look it up and set
+ final Context context = this.getInitialContext();
+ endpointAccessBean = (EndpointAccessRemoteBusiness) context.lookup(EndpointAccessRemoteBusiness.JNDI_NAME);
+ }
+
+ // Return
+ return endpointAccessBean;
+ }
+
+ /**
+ * Creates a new test SFSB session and returns the reference
+ * @return
+ * @throws Throwable
+ */
+ private StatefulRemoteBusiness getSfsb() throws Throwable
+ {
+ // Look up and return
+ final Context context = this.getInitialContext();
+ return (StatefulRemoteBusiness) context.lookup(StatefulRemoteBusiness.JNDI_NAME);
+ }
+}
More information about the jboss-cvs-commits
mailing list