[jboss-cvs] JBossAS SVN: r79439 - in projects/metadata/trunk/src: main/java/org/jboss/metadata/common/spi and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Oct 13 23:04:52 EDT 2008


Author: ALRubinger
Date: 2008-10-13 23:04:51 -0400 (Mon, 13 Oct 2008)
New Revision: 79439

Added:
   projects/metadata/trunk/src/main/java/org/jboss/metadata/common/spi/
   projects/metadata/trunk/src/main/java/org/jboss/metadata/common/spi/ErrorCodes.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta117/
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta117/TestBeanWithLocalBindingButNoLocalBusinessInterface.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta117/TestBeanWithRemoteBindingButNoRemoteBusinessInterface.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta117/TestLocal.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta117/TestRemote.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta117/unit/
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta117/unit/BindingsWithNoAssociatedBusinessInterfaceTestCase.java
Log:
[JBMETA-117] Addded Unit Test

Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/common/spi/ErrorCodes.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/common/spi/ErrorCodes.java	                        (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/common/spi/ErrorCodes.java	2008-10-14 03:04:51 UTC (rev 79439)
@@ -0,0 +1,39 @@
+/*
+ * 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.metadata.common.spi;
+
+/**
+ * ErrorCodes
+ * 
+ * Contains contracted error codes used in error messages
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface ErrorCodes
+{
+   /*
+    * Error Code Definitions
+    */
+
+   String ERROR_CODE_JBMETA117 = "JBMETA-117";
+}

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta117/TestBeanWithLocalBindingButNoLocalBusinessInterface.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta117/TestBeanWithLocalBindingButNoLocalBusinessInterface.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta117/TestBeanWithLocalBindingButNoLocalBusinessInterface.java	2008-10-14 03:04:51 UTC (rev 79439)
@@ -0,0 +1,45 @@
+/*
+ * 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.test.metadata.jbmeta117;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+
+import org.jboss.ejb3.annotation.LocalBinding;
+
+/**
+ * TestBeanWithLocalBindingButNoLocalBusinessInterface
+ * 
+ * A Test EJB which declares @LocalBinding
+ * but has no local business interface.  Should 
+ * fail deployment
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+ at Stateless
+ at Remote(TestRemote.class)
+ at LocalBinding(jndiBinding = "SomethingFake")
+public class TestBeanWithLocalBindingButNoLocalBusinessInterface
+{
+
+}

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta117/TestBeanWithRemoteBindingButNoRemoteBusinessInterface.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta117/TestBeanWithRemoteBindingButNoRemoteBusinessInterface.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta117/TestBeanWithRemoteBindingButNoRemoteBusinessInterface.java	2008-10-14 03:04:51 UTC (rev 79439)
@@ -0,0 +1,45 @@
+/*
+ * 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.test.metadata.jbmeta117;
+
+import javax.ejb.Local;
+import javax.ejb.Stateless;
+
+import org.jboss.ejb3.annotation.RemoteBinding;
+
+/**
+ * TestBeanWithRemoteBindingButNoRemoteBusinessInterface
+ * 
+ * A Test EJB which declares @RemoteBinding
+ * but has no remote business interface.  Should 
+ * fail deployment
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+ at Stateless
+ at Local(TestLocal.class)
+ at RemoteBinding(jndiBinding = "FakeRemoteBinding")
+public class TestBeanWithRemoteBindingButNoRemoteBusinessInterface
+{
+
+}

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta117/TestLocal.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta117/TestLocal.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta117/TestLocal.java	2008-10-14 03:04:51 UTC (rev 79439)
@@ -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.test.metadata.jbmeta117;
+
+/**
+ * TestLocal
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface TestLocal
+{
+
+}

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta117/TestRemote.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta117/TestRemote.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta117/TestRemote.java	2008-10-14 03:04:51 UTC (rev 79439)
@@ -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.test.metadata.jbmeta117;
+
+/**
+ * TestRemote
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface TestRemote
+{
+
+}

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta117/unit/BindingsWithNoAssociatedBusinessInterfaceTestCase.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta117/unit/BindingsWithNoAssociatedBusinessInterfaceTestCase.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta117/unit/BindingsWithNoAssociatedBusinessInterfaceTestCase.java	2008-10-14 03:04:51 UTC (rev 79439)
@@ -0,0 +1,125 @@
+/*
+ * 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.test.metadata.jbmeta117.unit;
+
+import java.lang.reflect.AnnotatedElement;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import junit.framework.TestCase;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.annotation.creator.ejb.jboss.JBoss50Creator;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.annotation.finder.DefaultAnnotationFinder;
+import org.jboss.metadata.common.spi.ErrorCodes;
+import org.jboss.test.metadata.jbmeta117.TestBeanWithLocalBindingButNoLocalBusinessInterface;
+import org.jboss.test.metadata.jbmeta117.TestBeanWithRemoteBindingButNoRemoteBusinessInterface;
+
+/**
+ * BindingsWithNoAssociatedBusinessInterfaceTestCase
+ * 
+ * Tests EJBs that have @LocalBinding/@RemoteBinding specified, 
+ * but no corresponding local or remote business interface
+ * 
+ * JBMETA-117
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class BindingsWithNoAssociatedBusinessInterfaceTestCase extends TestCase
+{
+   // -------------------------------------------------------------------||
+   // Class Members -----------------------------------------------------||
+   // -------------------------------------------------------------------||
+
+   private static final Logger log = Logger.getLogger(BindingsWithNoAssociatedBusinessInterfaceTestCase.class);
+
+   // -------------------------------------------------------------------||
+   // Tests -------------------------------------------------------------||
+   // -------------------------------------------------------------------||
+
+   /**
+    * Tests that an EJB declaring a @LocalBinding with no
+    * local business interface fails creation
+    */
+   public void testLocalBindingNoLocalBusinessInterface() throws Throwable
+   {
+      this.testFailsCreation(TestBeanWithLocalBindingButNoLocalBusinessInterface.class);
+   }
+
+   /**
+    * Tests that an EJB declaring a @RemoteBinding with no
+    * remote business interface fails creation
+    */
+   public void testRemoteBindingNoRemoteBusinessInterface() throws Throwable
+   {
+      this.testFailsCreation(TestBeanWithRemoteBindingButNoRemoteBusinessInterface.class);
+   }
+
+   // -------------------------------------------------------------------||
+   // Internal Helper Methods -------------------------------------------||
+   // -------------------------------------------------------------------||
+
+   protected void testFailsCreation(Class<?> ejbImplementationClass)
+   {
+      /*
+       * Set up a JBoss Metadata Creator
+       */
+
+      // MAke an annotation finder
+      AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+
+      // Configure to scan the test EJB
+      Collection<Class<?>> classes = new ArrayList<Class<?>>();
+      classes.add(TestBeanWithRemoteBindingButNoRemoteBusinessInterface.class);
+      JBoss50Creator creator = new JBoss50Creator(finder);
+
+      // Make the metadata
+      try
+      {
+         creator.create(classes);
+      }
+      // Expected
+      catch (Throwable t)
+      {
+         // Get the expected error code
+         String errorCode =ErrorCodes.ERROR_CODE_JBMETA117;
+         
+         // Get the error message
+         String errorMessage = t.getMessage();
+         
+         // Ensure the code is in the error message, so we've got the right exception
+         TestCase.assertTrue("Creation failed as expected, but error code of " + errorCode
+               + " was not referenced.  Instead error was: " + errorMessage, errorMessage.contains(errorCode));
+         
+         // Return
+         return;
+      }
+
+      // If we've reached here, creation succeeded and the test fails
+      TestCase.fail("Metadata from invalid construct was improperly completed in "
+            + "creation for EJB with Implementation Class " + ejbImplementationClass.getName());
+
+   }
+
+}




More information about the jboss-cvs-commits mailing list