[jboss-cvs] JBossAS SVN: r72026 - in projects/microcontainer/trunk/kernel/src: resources/tests/org/jboss/test/kernel/deployment/test and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Apr 11 10:59:49 EDT 2008


Author: alesj
Date: 2008-04-11 10:59:49 -0400 (Fri, 11 Apr 2008)
New Revision: 72026

Added:
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/test/BeanContainerInjectionTestCase.xml
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/EJB.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/EJBAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/InjectWrapperFieldAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/OtherSessionBean.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/TestSessionBean.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/BeanContainerInjectionTestCase.java
Modified:
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InjectableMemberAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/BeanContainerScopingTestCase.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/DeploymentTestSuite.java
Log:
Bean container injection test case.

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InjectableMemberAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InjectableMemberAnnotationPlugin.java	2008-04-11 14:47:24 UTC (rev 72025)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InjectableMemberAnnotationPlugin.java	2008-04-11 14:59:49 UTC (rev 72026)
@@ -101,7 +101,7 @@
     */
    protected PropertyMetaData getPropertyMetaData(T info, C annotation)
    {
-      ValueMetaData value = createValueMetaData(annotation);
+      ValueMetaData value = createValueMetaData(info, annotation);
       if (value == null)
          throw new IllegalArgumentException("Should not return null value, " + this);
 
@@ -129,8 +129,23 @@
    /**
     * Create value meta data.
     *
+    * @param info the info
     * @param annotation the annotation
+    * @return value metadata
+    */
+   protected ValueMetaData createValueMetaData(T info, C annotation)
+   {
+      return createValueMetaData(annotation);
+   }
+
+   /**
+    * Create value meta data.
+    *
+    * @param annotation the annotation
     * @return value meta data
     */
-   public abstract ValueMetaData createValueMetaData(C annotation);
+   public ValueMetaData createValueMetaData(C annotation)
+   {
+      throw new IllegalArgumentException("Missing createValueMetaData(" + getAnnotation() + ") implementation!");  
+   }
 }

Copied: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/test/BeanContainerInjectionTestCase.xml (from rev 72020, projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/test/BeanContainerScopingTestCase.xml)
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/test/BeanContainerInjectionTestCase.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/test/BeanContainerInjectionTestCase.xml	2008-04-11 14:59:49 UTC (rev 72026)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+  <bean name="InjectPlugin" class="org.jboss.test.kernel.deployment.support.container.InjectWrapperFieldAnnotationPlugin"/>
+
+  <bean name="EJBPlugin" class="org.jboss.test.kernel.deployment.support.container.EJBAnnotationPlugin">
+    <property name="prefix">java:env/comp</property>
+  </bean>
+
+  <bean name="BMDAdapter" class="org.jboss.kernel.plugins.annotations.AbstractMetaDataAnnotationAdapter">
+    <incallback method="addAnnotationPlugin"/>
+    <uncallback method="removeAnnotationPlugin"/>
+  </bean>
+
+  <!-- mock jndi bean -->
+  <bean name="java:env/comp/other" class="org.jboss.test.kernel.deployment.support.container.OtherSessionBean"/>
+
+</deployment>

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/EJB.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/EJB.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/EJB.java	2008-04-11 14:59:49 UTC (rev 72026)
@@ -0,0 +1,37 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., 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.kernel.deployment.support.container;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.FIELD, ElementType.METHOD})
+public @interface EJB
+{
+   String value() default "";
+}

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/EJBAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/EJBAnnotationPlugin.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/EJBAnnotationPlugin.java	2008-04-11 14:59:49 UTC (rev 72026)
@@ -0,0 +1,55 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., 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.kernel.deployment.support.container;
+
+import org.jboss.beans.metadata.plugins.AbstractDependencyValueMetaData;
+import org.jboss.beans.metadata.spi.ValueMetaData;
+import org.jboss.kernel.plugins.annotations.FieldAnnotationPlugin;
+import org.jboss.reflect.spi.FieldInfo;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class EJBAnnotationPlugin extends FieldAnnotationPlugin<EJB>
+{
+   private String prefix = "";
+
+   public EJBAnnotationPlugin()
+   {
+      super(EJB.class);
+   }
+
+   public ValueMetaData createValueMetaData(FieldInfo info, EJB annotation)
+   {
+      String name = prefix + "/";
+      if (isAttributePresent(annotation.value()))
+         name += annotation.value();
+      else
+         name += getName(info);
+      return new AbstractDependencyValueMetaData(name);
+   }
+
+   public void setPrefix(String prefix)
+   {
+      this.prefix = prefix;
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/InjectWrapperFieldAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/InjectWrapperFieldAnnotationPlugin.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/InjectWrapperFieldAnnotationPlugin.java	2008-04-11 14:59:49 UTC (rev 72026)
@@ -0,0 +1,31 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., 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.kernel.deployment.support.container;
+
+import org.jboss.kernel.plugins.annotations.InjectFieldAnnotationPlugin;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class InjectWrapperFieldAnnotationPlugin extends InjectFieldAnnotationPlugin
+{
+}

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/OtherSessionBean.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/OtherSessionBean.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/OtherSessionBean.java	2008-04-11 14:59:49 UTC (rev 72026)
@@ -0,0 +1,29 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., 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.kernel.deployment.support.container;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class OtherSessionBean
+{
+}

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/TestSessionBean.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/TestSessionBean.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/TestSessionBean.java	2008-04-11 14:59:49 UTC (rev 72026)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., 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.kernel.deployment.support.container;
+
+import org.jboss.beans.metadata.api.annotations.Inject;
+import org.jboss.dependency.spi.Controller;
+import org.jboss.kernel.plugins.bootstrap.basic.KernelConstants;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class TestSessionBean
+{
+   @EJB
+   private OtherSessionBean other;
+
+   @Inject(bean = KernelConstants.KERNEL_CONTROLLER_NAME)
+   private Controller controller;
+
+   public void validate()
+   {
+      if (other == null)
+         throw new RuntimeException("Other is null");
+      if (controller == null)
+         throw new RuntimeException("Controller is null");
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/BeanContainerInjectionTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/BeanContainerInjectionTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/BeanContainerInjectionTestCase.java	2008-04-11 14:59:49 UTC (rev 72026)
@@ -0,0 +1,63 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., 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.kernel.deployment.test;
+
+import junit.framework.Test;
+import org.jboss.beans.info.spi.BeanAccessMode;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.kernel.spi.annotations.AnnotationToBeanMetaDataFactory;
+import org.jboss.kernel.spi.annotations.BeanMetaDataAnnotationAdapter;
+import org.jboss.test.kernel.deployment.support.container.TestSessionBean;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BeanContainerInjectionTestCase extends AbstractDeploymentTest
+{
+   public BeanContainerInjectionTestCase(String name) throws Throwable
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(BeanContainerInjectionTestCase.class);
+   }
+
+   public void testContainerInjection() throws Throwable
+   {
+      BeanMetaDataAnnotationAdapter adapter = assertBean("BMDAdapter", BeanMetaDataAnnotationAdapter.class);
+      BeanMetaData bmd = AnnotationToBeanMetaDataFactory.createBeanMetaData(TestSessionBean.class, BeanAccessMode.ALL, adapter);
+      bmd.setName("test");
+      SecurityManager sm = suspendSecurity();
+      try
+      {
+         deploy(bmd);
+      }
+      finally
+      {
+         resumeSecurity(sm);   
+      }
+      TestSessionBean tsb = assertBean("test", TestSessionBean.class);
+      tsb.validate();
+   }
+}

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/BeanContainerScopingTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/BeanContainerScopingTestCase.java	2008-04-11 14:47:24 UTC (rev 72025)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/BeanContainerScopingTestCase.java	2008-04-11 14:59:49 UTC (rev 72026)
@@ -23,9 +23,10 @@
 
 import java.util.List;
 
+import junit.framework.Test;
 import org.jboss.test.kernel.deployment.support.container.BaseContext;
+import org.jboss.test.kernel.deployment.support.container.InstanceInterceptor;
 import org.jboss.test.kernel.deployment.support.container.ScopedContainer;
-import org.jboss.test.kernel.deployment.support.container.InstanceInterceptor;
 
 /**
  * Test controller scopes.
@@ -39,6 +40,11 @@
       super(name);
    }
 
+   public static Test suite()
+   {
+      return suite(BeanContainerScopingTestCase.class);
+   }
+
    public void testControllerScopes() throws Throwable
    {
       ScopedContainer sc1 = assertBean("CF1", ScopedContainer.class);

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/DeploymentTestSuite.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/DeploymentTestSuite.java	2008-04-11 14:47:24 UTC (rev 72025)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/DeploymentTestSuite.java	2008-04-11 14:59:49 UTC (rev 72026)
@@ -65,6 +65,11 @@
       suite.addTest(InCallbackInstantiatedTestCase.suite());
       suite.addTest(AnonymousBeansTestCase.suite());
       suite.addTest(AnonymousBeansXMLTestCase.suite());
+      // bean container tests
+      suite.addTest(BeanContainerUsageTestCase.suite());
+      suite.addTest(BeanContainerUsageMDTestCase.suite());
+      suite.addTest(BeanContainerScopingTestCase.suite());
+      suite.addTest(BeanContainerInjectionTestCase.suite());
 
       return suite;
    }




More information about the jboss-cvs-commits mailing list