[jboss-cvs] JBossAS SVN: r67831 - in trunk/ejb3/src/test/org/jboss/ejb3/test: ejbthree1090 and 7 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Dec 3 20:04:26 EST 2007


Author: bdecoste
Date: 2007-12-03 20:04:26 -0500 (Mon, 03 Dec 2007)
New Revision: 67831

Added:
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1090/
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1090/AopInterceptor.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1090/Ejb3Interceptor.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1090/StatefulBean.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1090/StatefulRemote.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1090/unit/
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1090/unit/InterceptorsUnitTestCase.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1092/
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1092/StatelessBean.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1092/StatelessRemote.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1092/unit/
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1092/unit/StatelessTestCase.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree994/
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree994/BusinessInterface.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree994/StatefulBean.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree994/unit/
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree994/unit/MultiBindingsTestCase.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/jbas4489/
   trunk/ejb3/src/test/org/jboss/ejb3/test/jbas4489/BMTCleanUp.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/jbas4489/BMTCleanUpBean.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/jbas4489/unit/
   trunk/ejb3/src/test/org/jboss/ejb3/test/jbas4489/unit/BMTCleanUpUnitTestCase.java
Log:
[EJBTHREE-1120] merged tests from Branch_4_2

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1090/AopInterceptor.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1090/AopInterceptor.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1090/AopInterceptor.java	2007-12-04 01:04:26 UTC (rev 67831)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejbthree1090;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.logging.Logger;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public class AopInterceptor implements Interceptor, java.io.Serializable
+{
+   private static final Logger log = Logger.getLogger(AopInterceptor.class);
+   
+   public AopInterceptor()
+   {
+   }
+
+   public String getName()
+   {
+      return "AopInterceptor";
+   }
+
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+      try 
+      {
+         log.info("*** Intercepting in AopInterceptor" );
+         invocation.invokeNext();
+         return ":Aop Intercepted";
+      } 
+      finally
+      {
+      }
+   }
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1090/Ejb3Interceptor.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1090/Ejb3Interceptor.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1090/Ejb3Interceptor.java	2007-12-04 01:04:26 UTC (rev 67831)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejbthree1090;
+
+import java.io.Serializable;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @version $Revision: 57207 $
+ */
+public class Ejb3Interceptor implements Serializable
+{
+   private static final Logger log = Logger.getLogger(Ejb3Interceptor.class);
+   
+   private static boolean called = false;
+   
+   public Ejb3Interceptor()
+   {
+   }
+   
+   @AroundInvoke
+   public Object intercept(InvocationContext ctx) throws Exception
+   {
+      try
+      {
+         log.info("*** Intercepting in Ejb3Interceptor");
+         // This is to skip the second instance of the interceptor due to @Interceptors being TYPE and METHOD
+         if (called)
+         {
+            return ctx.proceed();
+         }
+         else
+         {
+            called = true;
+            return "Ejb3 Intercepted" + ctx.proceed();
+         }
+      }
+      finally
+      {
+      }
+   }
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1090/StatefulBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1090/StatefulBean.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1090/StatefulBean.java	2007-12-04 01:04:26 UTC (rev 67831)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejbthree1090;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+
+import org.jboss.ejb3.annotation.AspectDomain;
+import org.jboss.logging.Logger;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * @version $Revision: 60233 $
+ */
+ at Stateful
+ at Remote(StatefulRemote.class)
+ at AspectDomain("Test Stateful Bean")
+//@javax.interceptor.Interceptors(value={org.jboss.ejb3.test.ejbthree1090.Ejb3Interceptor.class})
+public class StatefulBean
+   implements StatefulRemote
+{
+   private static final Logger log = Logger.getLogger(StatefulBean.class);
+   
+   public String test() throws Exception
+   {
+      return "Not intercepted";
+   }
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1090/StatefulRemote.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1090/StatefulRemote.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1090/StatefulRemote.java	2007-12-04 01:04:26 UTC (rev 67831)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejbthree1090;
+
+
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface StatefulRemote
+{
+   public String test() throws Exception;
+
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1090/unit/InterceptorsUnitTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1090/unit/InterceptorsUnitTestCase.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1090/unit/InterceptorsUnitTestCase.java	2007-12-04 01:04:26 UTC (rev 67831)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejbthree1090.unit;
+
+import org.jboss.ejb3.test.ejbthree1090.StatefulRemote;
+
+import org.jboss.logging.Logger;
+import org.jboss.test.JBossTestCase;
+import junit.framework.Test;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * @version $Revision: 60233 $
+ */
+public class InterceptorsUnitTestCase
+extends JBossTestCase
+{
+   private static final Logger log = Logger.getLogger(InterceptorsUnitTestCase.class);
+
+   public InterceptorsUnitTestCase(String name)
+   {
+      super(name);
+   }
+   
+   public void testAspectDomain() throws Exception
+   {
+      StatefulRemote stateful = (StatefulRemote)getInitialContext().lookup("StatefulBean/remote");
+      String result = stateful.test();
+      System.out.println(result);
+      assertEquals("Ejb3 Intercepted:Aop Intercepted", result);
+   }
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(InterceptorsUnitTestCase.class, "ejbthree1090-test.jar");
+   }
+
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1092/StatelessBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1092/StatelessBean.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1092/StatelessBean.java	2007-12-04 01:04:26 UTC (rev 67831)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejbthree1092;
+
+import javax.ejb.Stateless;
+import javax.ejb.Remote;
+
+import org.jboss.ejb3.annotation.Clustered;
+import org.jboss.ha.framework.interfaces.RandomRobin;
+import org.jboss.ha.framework.interfaces.RoundRobin;
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Stateless
+ at Remote(StatelessRemote.class)
+ at Clustered(loadBalancePolicy = RandomRobin.class)
+public class StatelessBean implements StatelessRemote
+{
+   private static final Logger log = Logger.getLogger(StatelessBean.class);
+   
+   public void test(int count)
+   {
+      log.info("****************** test " + count);
+   }
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1092/StatelessRemote.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1092/StatelessRemote.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1092/StatelessRemote.java	2007-12-04 01:04:26 UTC (rev 67831)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejbthree1092;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface StatelessRemote
+{
+   void test(int count);
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1092/unit/StatelessTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1092/unit/StatelessTestCase.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1092/unit/StatelessTestCase.java	2007-12-04 01:04:26 UTC (rev 67831)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejbthree1092.unit;
+
+import org.jboss.ejb3.test.ejbthree1092.StatelessRemote;
+
+import org.jboss.logging.Logger;
+import org.jboss.test.JBossTestCase;
+import junit.framework.Test;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public class StatelessTestCase extends JBossTestCase
+{
+   private static final Logger log = Logger.getLogger(StatelessTestCase.class);
+
+   public StatelessTestCase(String name)
+   {
+      super(name);
+   }
+ 
+   public void testLoadBalanceOverride() throws Exception
+   {
+      StatelessRemote stateless = (StatelessRemote) getInitialContext().lookup("StatelessBean/remote");
+      assertNotNull(stateless);
+      
+      for(int i = 0 ; i < 20 ; ++i)
+      {
+         stateless.test(i);
+         Thread.sleep(500);
+      }
+   }
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(StatelessTestCase.class, ""); //"ejbthree1092-test.jar");
+   }
+}
\ No newline at end of file

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree994/BusinessInterface.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree994/BusinessInterface.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree994/BusinessInterface.java	2007-12-04 01:04:26 UTC (rev 67831)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.ejbthree994;
+
+/**
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: 63662 $
+ */
+public interface BusinessInterface
+{
+   String echo(String s);
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree994/StatefulBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree994/StatefulBean.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree994/StatefulBean.java	2007-12-04 01:04:26 UTC (rev 67831)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.ejbthree994;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.ejb3.annotation.RemoteBindings;
+
+/**
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: 63662 $
+ */
+ at Stateful
+ at RemoteBindings({
+   @RemoteBinding(clientBindUrl="socket://0.0.0.0:3873", jndiBinding="Stateful3873"),
+   @RemoteBinding(clientBindUrl="socket://0.0.0.0:3874", jndiBinding="Stateful3874")
+})
+ at Remote(BusinessInterface.class)
+public class StatefulBean implements BusinessInterface
+{
+   public String echo(String s)
+   {
+      return "*** " + s + " ***";
+   }
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree994/unit/MultiBindingsTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree994/unit/MultiBindingsTestCase.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree994/unit/MultiBindingsTestCase.java	2007-12-04 01:04:26 UTC (rev 67831)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.ejbthree994.unit;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.test.ejbthree994.BusinessInterface;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.test.JBossTestCase;
+
+
+/**
+ * Test if multiple remote bindings work correctly.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: 63662 $
+ */
+public class MultiBindingsTestCase extends JBossTestCase
+{
+
+   public MultiBindingsTestCase(String name)
+   {
+      super(name);
+   }
+
+   private static String getProxyUri(Object proxy) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException
+   {
+      InvocationHandler handler = Proxy.getInvocationHandler(proxy);
+      Field f = handler.getClass().getDeclaredField("uri");
+      f.setAccessible(true);
+      InvokerLocator locator = (InvokerLocator) f.get(handler);
+      return locator.getOriginalURI();
+   }
+   
+   public void test1() throws Exception
+   {
+      {
+         BusinessInterface bean = (BusinessInterface) getInitialContext().lookup("Stateful3873");
+         String actual = bean.echo("123");
+         assertEquals(actual, "*** 123 ***");
+         
+         String proxyUri = getProxyUri(bean);
+         assertEquals(proxyUri, "socket://0.0.0.0:3873");
+      }
+
+      {
+         BusinessInterface bean = (BusinessInterface) getInitialContext().lookup("Stateful3874");
+         String actual = bean.echo("456");
+         assertEquals(actual, "*** 456 ***");
+         
+         String proxyUri = getProxyUri(bean);
+         assertEquals(proxyUri, "socket://0.0.0.0:3874");
+      }
+   }
+   
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(MultiBindingsTestCase.class, "ejbthree994-connectors-service.xml,ejbthree994.jar");
+   }
+
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/jbas4489/BMTCleanUp.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/jbas4489/BMTCleanUp.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/jbas4489/BMTCleanUp.java	2007-12-04 01:04:26 UTC (rev 67831)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jbas4489;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: 63564 $
+ */
+public interface BMTCleanUp
+{
+   void doNormal();
+
+   void testIncomplete();
+
+   void doIncomplete();
+
+   void testTxTimeout();
+
+   void doTimeout();
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/jbas4489/BMTCleanUpBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/jbas4489/BMTCleanUpBean.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/jbas4489/BMTCleanUpBean.java	2007-12-04 01:04:26 UTC (rev 67831)
@@ -0,0 +1,140 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jbas4489;
+
+import javax.annotation.Resource;
+import javax.ejb.EJBException;
+import javax.ejb.Remote;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.transaction.UserTransaction;
+
+import org.jboss.logging.Logger;
+import org.jboss.tm.TransactionManagerLocator;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: 65875 $
+ */
+ at Stateless
+ at Remote(BMTCleanUp.class)
+ at TransactionManagement(TransactionManagementType.BEAN)
+public class BMTCleanUpBean implements BMTCleanUp
+{
+   private static final Logger log = Logger.getLogger(BMTCleanUpBean.class);
+   
+   @Resource
+   private SessionContext sessionCtx;
+   
+   private void checkTransaction()
+   {
+      TransactionManager tm = TransactionManagerLocator.getInstance().locate();
+      try
+      {
+         Transaction tx = tm.getTransaction();
+         if (tx != null)
+            throw new IllegalStateException("There should be no transaction context: " + tx);
+      }
+      catch (Exception e)
+      {
+         throw new EJBException("Error", e);
+      }
+   }
+
+   public void doIncomplete()
+   {
+      UserTransaction ut = sessionCtx.getUserTransaction();
+      try
+      {
+         ut.begin();
+      }
+      catch (Exception e)
+      {
+         throw new EJBException("Error", e);
+      }
+   }
+
+   public void doNormal()
+   {
+      UserTransaction ut = sessionCtx.getUserTransaction();
+      try
+      {
+         ut.begin();
+         ut.commit();
+      }
+      catch (Exception e)
+      {
+         throw new EJBException("Error", e);
+      }
+   }
+
+   public void doTimeout()
+   {
+      UserTransaction ut = sessionCtx.getUserTransaction();
+      try
+      {
+         ut.setTransactionTimeout(5);
+         ut.begin();
+         Thread.sleep(10000);
+         log.info("tx status: " + ut.getStatus());
+      }
+      catch (InterruptedException ignored)
+      {
+      }
+      catch (Exception e)
+      {
+         throw new EJBException("Error", e);
+      }
+   }
+
+   public void testIncomplete()
+   {
+      BMTCleanUp remote = sessionCtx.getBusinessObject(BMTCleanUp.class);
+      try
+      {
+         remote.doIncomplete();
+         throw new RuntimeException("Expected an EJBException for incomplete transaction");
+      }
+      catch (EJBException expected)
+      {
+         // expected
+         log.debug("Expected exception", expected);
+      }
+      checkTransaction();
+      remote.doNormal();
+   }
+
+   public void testTxTimeout()
+   {
+      BMTCleanUp remote = sessionCtx.getBusinessObject(BMTCleanUp.class);
+      remote.doTimeout();
+      checkTransaction();
+      remote.doNormal();
+   }
+
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/jbas4489/unit/BMTCleanUpUnitTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/jbas4489/unit/BMTCleanUpUnitTestCase.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/jbas4489/unit/BMTCleanUpUnitTestCase.java	2007-12-04 01:04:26 UTC (rev 67831)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jbas4489.unit;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.test.jbas4489.BMTCleanUp;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: 63564 $
+ */
+public class BMTCleanUpUnitTestCase extends JBossTestCase
+{
+   public BMTCleanUpUnitTestCase(String name)
+   {
+      super(name);
+   }
+   
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(BMTCleanUpUnitTestCase.class, "jbas4489.jar");
+   }
+   
+   public void testIncomplete() throws Exception
+   {
+      BMTCleanUp bean = getBean();
+      bean.testIncomplete();
+   }
+   
+   public void testTxTimeout() throws Exception
+   {
+      BMTCleanUp bean = getBean();
+      bean.testTxTimeout();
+   }
+
+   private BMTCleanUp getBean() throws Exception
+   {
+      return (BMTCleanUp) getInitialContext().lookup("BMTCleanUpBean/remote");
+   }
+}




More information about the jboss-cvs-commits mailing list