[jboss-cvs] JBossAS SVN: r67290 - in projects/metadata/trunk/src/test/java/org/jboss/test/metadata: annotation/ejb3 and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Nov 20 06:08:02 EST 2007


Author: wolfc
Date: 2007-11-20 06:08:02 -0500 (Tue, 20 Nov 2007)
New Revision: 67290

Added:
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/multiview/
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/multiview/Multiview21Remote.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/multiview/Multiview3Remote.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/multiview/MultiviewBean.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/multiview/MultiviewHome.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/common/
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/common/SetHelper.java
Modified:
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/AnnotationEjb3UnitTestCase.java
Log:
JBAS-4506: Added test for multiview bean

Modified: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/AnnotationEjb3UnitTestCase.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/AnnotationEjb3UnitTestCase.java	2007-11-20 10:18:31 UTC (rev 67289)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/AnnotationEjb3UnitTestCase.java	2007-11-20 11:08:02 UTC (rev 67290)
@@ -73,7 +73,11 @@
 import org.jboss.metadata.javaee.spec.RunAsMetaData;
 import org.jboss.metadata.javaee.spec.SecurityRoleMetaData;
 import org.jboss.metadata.javaee.spec.SecurityRolesMetaData;
+import org.jboss.test.metadata.annotation.ejb3.multiview.Multiview21Remote;
+import org.jboss.test.metadata.annotation.ejb3.multiview.Multiview3Remote;
+import org.jboss.test.metadata.annotation.ejb3.multiview.MultiviewHome;
 import org.jboss.test.metadata.annotation.ejb3.runas.InterMediate;
+import org.jboss.test.metadata.common.SetHelper;
 import org.jboss.test.metadata.javaee.AbstractJavaEEMetaDataTest;
 import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
 import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver;
@@ -289,9 +293,14 @@
 
    private Collection<Class> loadClassesFromCurrentClassDir()
    {
+      return loadClassesFromRelativeClassDir(".");
+   }
+   
+   private Collection<Class> loadClassesFromRelativeClassDir(String dir)
+   {
       // In real life the deployer will pass probably pass a class scanner
       Collection<Class> classes = new ArrayList<Class>();
-      URL currentClassDirURL = getClass().getResource(".");
+      URL currentClassDirURL = getClass().getResource(dir);
       File currentDir;
       try
       {
@@ -312,9 +321,15 @@
       
       Arrays.sort(classFileNames);
       
+      String packageName;
+      if(dir.indexOf('/') != -1)
+         packageName = dir.replaceAll("\\/", "") + ".";
+      else
+         packageName = ".";
+      
       for(String classFileName : classFileNames)
       {
-         String className = getClass().getPackage().getName() + "." + classFileName.substring(0, classFileName.length() - 6);
+         String className = getClass().getPackage().getName() + packageName + classFileName.substring(0, classFileName.length() - 6);
          try
          {
             classes.add(Class.forName(className));
@@ -353,7 +368,7 @@
       
       assertEquals(7, metaData.getEnterpriseBeans().size());
       
-      assertMyStatefulBean(metaData.getEnterpriseBean("AnotherName"));
+      assertMyStatefulBean(metaData.getEnterpriseBean("AnotherName")); // MyStatefulBean
       assertMyStateless21Bean(metaData.getEnterpriseBean("MyStateless21Bean"));
       assertMyStatelessBean(metaData.getEnterpriseBean("MyStatelessBean"));
       assertMyEntity(metaData.getEnterpriseBean("MyEntity"));
@@ -445,5 +460,34 @@
       assertNotNull(runAs);
       assertEquals("InternalUser", runAs.getRoleName());
    }
+   
+   public void testMultiview() throws Exception
+   {
+      AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+      
+      Collection<Class> classes = loadClassesFromRelativeClassDir("./multiview");
+      System.out.println("Processing classes: "+classes);
+      
+      enableTrace("org.jboss.metadata.annotation.creator");
+      EjbJar30Creator creator = new EjbJar30Creator(finder);
+      
+      EjbJar30MetaData metaData = creator.create(classes);
+      
+      assertTrue(metaData.isEJB3x());
+      assertEquals("3.0", metaData.getVersion());
+      
+      assertNotNull("no beans defined", metaData.getEnterpriseBeans());
+      //assertNotNull("no assembly descriptor defined", metaData.getAssemblyDescriptor());
+      SessionBeanMetaData bean = (SessionBeanMetaData) metaData.getEnterpriseBean("MultiviewBean");
+      assertNotNull(bean);
+      assertEquals(MultiviewHome.class.getName(), bean.getHome());
+      assertEquals(Multiview21Remote.class.getName(), bean.getRemote());
+      assertEquals(SetHelper.createSet(Multiview3Remote.class.getName()), bean.getBusinessRemotes());
+      InitMethodsMetaData initMethods = bean.getInitMethods();
+      assertNotNull(initMethods);
+      assertEquals(1, initMethods.size());
+      InitMethodMetaData initMethod = initMethods.get(0);
+      assertEquals("create", initMethod.getBeanMethod().getMethodName());
+   }
 }
 

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/multiview/Multiview21Remote.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/multiview/Multiview21Remote.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/multiview/Multiview21Remote.java	2007-11-20 11:08:02 UTC (rev 67290)
@@ -0,0 +1,37 @@
+/*
+ * 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.test.metadata.annotation.ejb3.multiview;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.EJBObject;
+
+/**
+ * EJB 3 4.6.7
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface Multiview21Remote extends EJBObject
+{
+   String sayHi(String name) throws RemoteException;
+}


Property changes on: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/multiview/Multiview21Remote.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/multiview/Multiview3Remote.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/multiview/Multiview3Remote.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/multiview/Multiview3Remote.java	2007-11-20 11:08:02 UTC (rev 67290)
@@ -0,0 +1,37 @@
+/*
+ * 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.test.metadata.annotation.ejb3.multiview;
+
+import javax.ejb.Remote;
+
+/**
+ * EJB 4.6.6
+ * 
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Remote
+public interface Multiview3Remote
+{
+   void create(String state);
+   String sayHi(String name);
+}


Property changes on: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/multiview/Multiview3Remote.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/multiview/MultiviewBean.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/multiview/MultiviewBean.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/multiview/MultiviewBean.java	2007-11-20 11:08:02 UTC (rev 67290)
@@ -0,0 +1,53 @@
+/*
+ * 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.test.metadata.annotation.ejb3.multiview;
+
+import javax.ejb.Init;
+import javax.ejb.Remote;
+import javax.ejb.RemoteHome;
+import javax.ejb.Stateful;
+
+/**
+ * MultiviewBean provides both an EJB 3 and an EJB 2.1
+ * view. It is however a (EJB 3) POJO and not an EJB 2.1 bean.
+ * 
+ * EJB 3 4.6.2
+ * 
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Stateful
+ at RemoteHome(MultiviewHome.class)
+ at Remote(Multiview21Remote.class)
+public class MultiviewBean implements Multiview3Remote
+{
+   @Init
+   public void create(String state)
+   {
+      
+   }
+   
+   public String sayHi(String name)
+   {
+      return "Hi " + name;
+   }
+}


Property changes on: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/multiview/MultiviewBean.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/multiview/MultiviewHome.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/multiview/MultiviewHome.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/multiview/MultiviewHome.java	2007-11-20 11:08:02 UTC (rev 67290)
@@ -0,0 +1,38 @@
+/*
+ * 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.test.metadata.annotation.ejb3.multiview;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBHome;
+
+/**
+ * EJB 3 4.6.8
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface MultiviewHome extends EJBHome
+{
+   Multiview21Remote create(String state) throws CreateException, RemoteException;
+}


Property changes on: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/multiview/MultiviewHome.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/common/SetHelper.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/common/SetHelper.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/common/SetHelper.java	2007-11-20 11:08:02 UTC (rev 67290)
@@ -0,0 +1,51 @@
+/*
+ * 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.test.metadata.common;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * A utility class to handle sets.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class SetHelper
+{
+   /**
+    * Create a generic set from a variable amount of objects.
+    * 
+    * @param <T>    the type of element in the set
+    * @param obj    the objects
+    * @return       the created set
+    */
+   public static <T> Set<T> createSet(T ... obj)
+   {
+      Set<T> set = new HashSet<T>();
+      for(T o : obj)
+      {
+         set.add(o);
+      }
+      return set;
+   }
+}


Property changes on: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/common/SetHelper.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native




More information about the jboss-cvs-commits mailing list