[jboss-cvs] JBossAS SVN: r59441 - in trunk/ejb3/src/test/org/jboss/ejb3/test/interceptors3: . unit

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jan 9 12:20:11 EST 2007


Author: bstansberry at jboss.com
Date: 2007-01-09 12:20:09 -0500 (Tue, 09 Jan 2007)
New Revision: 59441

Added:
   trunk/ejb3/src/test/org/jboss/ejb3/test/interceptors3/AnnotatedAssemblyBean.java
Modified:
   trunk/ejb3/src/test/org/jboss/ejb3/test/interceptors3/AssemblyBean.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/interceptors3/AssemblyRemoteIF.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/interceptors3/unit/InterceptorsTestCase.java
Log:
Add test where multiple methods are invoked and also where annotation is used

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/interceptors3/AnnotatedAssemblyBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/interceptors3/AnnotatedAssemblyBean.java	2007-01-09 15:34:44 UTC (rev 59440)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/interceptors3/AnnotatedAssemblyBean.java	2007-01-09 17:20:09 UTC (rev 59441)
@@ -0,0 +1,41 @@
+/*
+ * 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.interceptors3;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+import javax.interceptor.Interceptors;
+
+/**
+ * AssemblyBean subclass that uses an annotation to add the interceptor.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+ at Stateful
+ at Remote(AssemblyRemoteIF.class)
+ at Interceptors({AssemblyInterceptor.class})
+public class AnnotatedAssemblyBean extends AssemblyBean
+{
+
+}

Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/interceptors3/AssemblyBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/interceptors3/AssemblyBean.java	2007-01-09 15:34:44 UTC (rev 59440)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/interceptors3/AssemblyBean.java	2007-01-09 17:20:09 UTC (rev 59441)
@@ -21,6 +21,7 @@
  */
 package org.jboss.ejb3.test.interceptors3;
 
+
 /**
  * Comment
  *
@@ -34,5 +35,10 @@
    {
       return a + b;
    }
+   
+   public int remoteMultiply(int a, int b)
+   {
+      return a * b;
+   }
 
 }

Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/interceptors3/AssemblyRemoteIF.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/interceptors3/AssemblyRemoteIF.java	2007-01-09 15:34:44 UTC (rev 59440)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/interceptors3/AssemblyRemoteIF.java	2007-01-09 17:20:09 UTC (rev 59441)
@@ -27,4 +27,5 @@
 public interface AssemblyRemoteIF
 {
    int remoteAdd(int a, int b);
+   int remoteMultiply(int a, int b);
 }

Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/interceptors3/unit/InterceptorsTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/interceptors3/unit/InterceptorsTestCase.java	2007-01-09 15:34:44 UTC (rev 59440)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/interceptors3/unit/InterceptorsTestCase.java	2007-01-09 17:20:09 UTC (rev 59441)
@@ -41,9 +41,39 @@
 
    public void testIntercept() throws Exception
    {
-      AssemblyRemoteIF bean = (AssemblyRemoteIF) getInitialContext().lookup("AssemblyBean/remote");
+      interceptTest("AssemblyBean/remote");
+   }
+
+   public void testInterceptAnnotated() throws Exception
+   {
+      interceptTest("AnnotatedAssemblyBean/remote");
+   }
+   
+   private void interceptTest(String jndi) throws Exception
+   {
+      AssemblyRemoteIF bean = (AssemblyRemoteIF) getInitialContext().lookup(jndi);
       int actual = bean.remoteAdd(1, 2);
+      assertEquals(203, actual);      
+   }
+
+   public void testInterceptDifferentMethods() throws Exception
+   {
+      interceptDifferentMethodsTest("AssemblyBean/remote");
+   }
+
+   public void testInterceptDifferentMethodsAnnotated() throws Exception
+   {
+      interceptDifferentMethodsTest("AnnotatedAssemblyBean/remote");
+   }
+   
+   private void interceptDifferentMethodsTest(String jndi) throws Exception
+   {
+      AssemblyRemoteIF bean = (AssemblyRemoteIF) getInitialContext().lookup(jndi);
+      int actual = bean.remoteAdd(1, 2);
       assertEquals(203, actual);
+      
+      actual = bean.remoteMultiply(0, 0);
+      assertEquals(10000, actual);
    }
    
    public static Test suite() throws Exception




More information about the jboss-cvs-commits mailing list