[jboss-cvs] JBossAS SVN: r77003 - in projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean: support and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Aug 13 04:41:38 EDT 2008


Author: alesj
Date: 2008-08-13 04:41:38 -0400 (Wed, 13 Aug 2008)
New Revision: 77003

Added:
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/support/SimpleAliasTester.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/support/SimpleConstructorTester.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/support/SimpleInjectionTester.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/support/SimpleStartTester.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/test/AbstractAnnotationBeansTest.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/test/BuilderBeansUnitTestCase.java
Modified:
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/BeanDeployerTestSuite.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/test/AnnotatedBeansUnitTestCase.java
Log:
Test @Aliases via BMDBuilder.

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/BeanDeployerTestSuite.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/BeanDeployerTestSuite.java	2008-08-13 08:38:46 UTC (rev 77002)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/BeanDeployerTestSuite.java	2008-08-13 08:41:38 UTC (rev 77003)
@@ -21,20 +21,20 @@
 */
 package org.jboss.test.deployers.vfs.deployer.bean;
 
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+import org.jboss.test.deployers.vfs.deployer.bean.test.AliasDeployerUnitTestCase;
+import org.jboss.test.deployers.vfs.deployer.bean.test.AnnotatedBeansUnitTestCase;
 import org.jboss.test.deployers.vfs.deployer.bean.test.BeanDeployerClassLoaderUnitTestCase;
 import org.jboss.test.deployers.vfs.deployer.bean.test.BeanDeployerUnitTestCase;
-import org.jboss.test.deployers.vfs.deployer.bean.test.KernelDeployerUnitTestCase;
-import org.jboss.test.deployers.vfs.deployer.bean.test.AliasDeployerUnitTestCase;
-import org.jboss.test.deployers.vfs.deployer.bean.test.BeanScanningUnitTestCase;
 import org.jboss.test.deployers.vfs.deployer.bean.test.BeanManagedDeploymentUnitTestCase;
 import org.jboss.test.deployers.vfs.deployer.bean.test.BeanMetaDataFactoryDeployerUnitTestCase;
+import org.jboss.test.deployers.vfs.deployer.bean.test.BeanScanningUnitTestCase;
+import org.jboss.test.deployers.vfs.deployer.bean.test.BuilderBeansUnitTestCase;
+import org.jboss.test.deployers.vfs.deployer.bean.test.KernelDeployerUnitTestCase;
 import org.jboss.test.deployers.vfs.deployer.bean.test.KernelScopeUnitTestCase;
-import org.jboss.test.deployers.vfs.deployer.bean.test.AnnotatedBeansUnitTestCase;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
 /**
  * BeanDeployerTestSuite.
  * 
@@ -62,6 +62,7 @@
       suite.addTest(BeanMetaDataFactoryDeployerUnitTestCase.suite());
       suite.addTest(KernelScopeUnitTestCase.suite());
       suite.addTest(AnnotatedBeansUnitTestCase.suite());
+      suite.addTest(BuilderBeansUnitTestCase.suite());
 
       return suite;
    }

Added: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/support/SimpleAliasTester.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/support/SimpleAliasTester.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/support/SimpleAliasTester.java	2008-08-13 08:41:38 UTC (rev 77003)
@@ -0,0 +1,42 @@
+/*
+* 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.deployers.vfs.deployer.bean.support;
+
+import org.jboss.dependency.spi.Controller;
+
+/**
+ * Simple constructor.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SimpleAliasTester extends SimpleAnnotated
+{
+   public static SimpleAnnotatedAlias factory()
+   {
+      return new SimpleAnnotatedAlias();
+   }
+
+   public void setController(Controller controller)
+   {
+      this.controller = controller;
+   }
+}
\ No newline at end of file

Copied: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/support/SimpleConstructorTester.java (from rev 76940, projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/support/SimpleAnnotatedConstructor.java)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/support/SimpleConstructorTester.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/support/SimpleConstructorTester.java	2008-08-13 08:41:38 UTC (rev 77003)
@@ -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.deployers.vfs.deployer.bean.support;
+
+import org.jboss.dependency.spi.Controller;
+
+/**
+ * Simple constructor.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SimpleConstructorTester extends SimpleAnnotated
+{
+   public SimpleConstructorTester(Controller controller)
+   {
+      this.controller = controller;
+   }
+}
\ No newline at end of file

Added: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/support/SimpleInjectionTester.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/support/SimpleInjectionTester.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/support/SimpleInjectionTester.java	2008-08-13 08:41:38 UTC (rev 77003)
@@ -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.deployers.vfs.deployer.bean.support;
+
+import org.jboss.dependency.spi.Controller;
+
+/**
+ * Simple constructor.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SimpleInjectionTester extends SimpleAnnotated
+{
+   public void setController(Controller controller)
+   {
+      this.controller = controller;
+   }
+}
\ No newline at end of file

Added: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/support/SimpleStartTester.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/support/SimpleStartTester.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/support/SimpleStartTester.java	2008-08-13 08:41:38 UTC (rev 77003)
@@ -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.deployers.vfs.deployer.bean.support;
+
+import org.jboss.dependency.spi.Controller;
+
+/**
+ * Simple constructor.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SimpleStartTester extends SimpleAnnotated
+{
+   public void onStart(Controller controller)
+   {
+      this.controller = controller;
+   }
+}
\ No newline at end of file

Added: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/test/AbstractAnnotationBeansTest.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/test/AbstractAnnotationBeansTest.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/test/AbstractAnnotationBeansTest.java	2008-08-13 08:41:38 UTC (rev 77003)
@@ -0,0 +1,103 @@
+/*
+* 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.deployers.vfs.deployer.bean.test;
+
+import java.util.Arrays;
+
+import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.deployers.client.spi.Deployment;
+import org.jboss.deployers.spi.attachments.MutableAttachments;
+import org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer;
+import org.jboss.deployers.vfs.deployer.kernel.KernelDeploymentDeployer;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
+import org.jboss.test.deployers.vfs.deployer.AbstractDeployerUnitTest;
+import org.jboss.test.deployers.vfs.deployer.bean.support.SimpleAnnotated;
+
+/**
+ * AbstractAnnotationBeansTest.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class AbstractAnnotationBeansTest extends AbstractDeployerUnitTest
+{
+   protected AbstractAnnotationBeansTest(String name) throws Throwable
+   {
+      super(name);
+   }
+
+   protected void addDeployers(Kernel kernel)
+   {
+      KernelDeploymentDeployer kernelDeploymentDeployer = new KernelDeploymentDeployer();
+      BeanMetaDataDeployer beanMetaDataDeployer = new BeanMetaDataDeployer(kernel.getController());
+      addDeployer(main, kernelDeploymentDeployer);
+      addDeployer(main, beanMetaDataDeployer);
+   }
+
+   protected abstract BeanMetaDataFactory getConstructorTester();
+   protected abstract BeanMetaDataFactory getInjectionTester();
+   protected abstract BeanMetaDataFactory getStartTester();
+   protected abstract BeanMetaDataFactory getAliasTester();
+
+   public void testAnnotatedBeans() throws Exception
+   {
+      Deployment context = createSimpleDeployment("KernelDeployerTest");
+
+      AbstractKernelDeployment deployment = new AbstractKernelDeployment();
+      deployment.setName("KernelDeployerTest");
+      BeanMetaDataFactory md1 = getConstructorTester();
+      BeanMetaDataFactory md2 = getInjectionTester();
+      BeanMetaDataFactory md3 = getStartTester();
+      BeanMetaDataFactory md4 = getAliasTester();
+      deployment.setBeanFactories(Arrays.asList(md1, md2, md3, md4));
+      MutableAttachments attachments = (MutableAttachments) context.getPredeterminedManagedObjects();
+      attachments.addAttachment("KernelDeployerTest", deployment);
+
+      assertDeploy(context);
+      try
+      {
+         assertSimpleAnnotated("Constructor");
+         assertSimpleAnnotated("Injection");
+         assertSimpleAnnotated("Start");
+         assertSimpleAnnotated("Alias");
+      }
+      finally
+      {
+         assertUndeploy(context);
+      }
+
+      assertNull(controller.getContext("Constructor", null));
+      assertNull(controller.getContext("Injection", null));
+      assertNull(controller.getContext("Start", null));
+      assertNull(controller.getContext("SomeRandomName", null));
+   }
+
+   protected void assertSimpleAnnotated(Object name)
+   {
+      ControllerContext context = controller.getInstalledContext(name);
+      assertNotNull("No such context: " + name, context);
+      Object target = context.getTarget();
+      SimpleAnnotated annotated = assertInstanceOf(target, SimpleAnnotated.class);
+      assertSame(controller, annotated.getController());
+   }
+}
\ No newline at end of file

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/test/AnnotatedBeansUnitTestCase.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/test/AnnotatedBeansUnitTestCase.java	2008-08-13 08:38:46 UTC (rev 77002)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/test/AnnotatedBeansUnitTestCase.java	2008-08-13 08:41:38 UTC (rev 77003)
@@ -21,21 +21,10 @@
 */
 package org.jboss.test.deployers.vfs.deployer.bean.test;
 
-import java.util.Arrays;
-
 import junit.framework.Test;
 import junit.framework.TestSuite;
 import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
 import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
-import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.deployers.client.spi.Deployment;
-import org.jboss.deployers.spi.attachments.MutableAttachments;
-import org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer;
-import org.jboss.deployers.vfs.deployer.kernel.KernelDeploymentDeployer;
-import org.jboss.kernel.Kernel;
-import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
-import org.jboss.test.deployers.vfs.deployer.AbstractDeployerUnitTest;
-import org.jboss.test.deployers.vfs.deployer.bean.support.SimpleAnnotated;
 import org.jboss.test.deployers.vfs.deployer.bean.support.SimpleAnnotatedAlias;
 import org.jboss.test.deployers.vfs.deployer.bean.support.SimpleAnnotatedConstructor;
 import org.jboss.test.deployers.vfs.deployer.bean.support.SimpleAnnotatedInjection;
@@ -46,7 +35,7 @@
  *
  * @author <a href="ales.justin at jboss.com">Ales Justin</a>
  */
-public class AnnotatedBeansUnitTestCase extends AbstractDeployerUnitTest
+public class AnnotatedBeansUnitTestCase extends AbstractAnnotationBeansTest
 {
    public static Test suite()
    {
@@ -58,54 +47,23 @@
       super(name);
    }
 
-   @SuppressWarnings("deprecation")
-   protected void addDeployers(Kernel kernel)
+   protected BeanMetaDataFactory getConstructorTester()
    {
-      KernelDeploymentDeployer kernelDeploymentDeployer = new KernelDeploymentDeployer();
-      BeanMetaDataDeployer beanMetaDataDeployer = new BeanMetaDataDeployer(kernel);
-      addDeployer(main, kernelDeploymentDeployer);
-      addDeployer(main, beanMetaDataDeployer);
+      return new AbstractBeanMetaData("Constructor", SimpleAnnotatedConstructor.class.getName());
    }
 
-   public void testKernelScope() throws Exception
+   protected BeanMetaDataFactory getInjectionTester()
    {
-      Deployment context = createSimpleDeployment("KernelDeployerTest");
+      return new AbstractBeanMetaData("Injection", SimpleAnnotatedInjection.class.getName());
+   }
 
-      AbstractKernelDeployment deployment = new AbstractKernelDeployment();
-      deployment.setName("KernelDeployerTest");
-      BeanMetaDataFactory md1 = new AbstractBeanMetaData("Constructor", SimpleAnnotatedConstructor.class.getName());
-      BeanMetaDataFactory md2 = new AbstractBeanMetaData("Injection", SimpleAnnotatedInjection.class.getName());
-      BeanMetaDataFactory md3 = new AbstractBeanMetaData("Start", SimpleAnnotatedStart.class.getName());
-      BeanMetaDataFactory md4 = new AbstractBeanMetaData("SomeRandomName", SimpleAnnotatedAlias.class.getName());
-      deployment.setBeanFactories(Arrays.asList(md1, md2, md3, md4));
-      MutableAttachments attachments = (MutableAttachments) context.getPredeterminedManagedObjects();
-      attachments.addAttachment("KernelDeployerTest", deployment);
-
-      assertDeploy(context);
-      try
-      {
-         assertSimpleAnnotated("Constructor");
-         assertSimpleAnnotated("Injection");
-         assertSimpleAnnotated("Start");
-         assertSimpleAnnotated("Alias");
-      }
-      finally
-      {
-         assertUndeploy(context);
-      }
-
-      assertNull(controller.getContext("Constructor", null));
-      assertNull(controller.getContext("Injection", null));
-      assertNull(controller.getContext("Start", null));
-      assertNull(controller.getContext("SomeRandomName", null));
+   protected BeanMetaDataFactory getStartTester()
+   {
+      return new AbstractBeanMetaData("Start", SimpleAnnotatedStart.class.getName());
    }
 
-   protected void assertSimpleAnnotated(Object name)
+   protected BeanMetaDataFactory getAliasTester()
    {
-      ControllerContext context = controller.getInstalledContext(name);
-      assertNotNull(context);
-      Object target = context.getTarget();
-      SimpleAnnotated annotated = assertInstanceOf(target, SimpleAnnotated.class);
-      assertSame(controller, annotated.getController());
+      return new AbstractBeanMetaData("SomeRandomName", SimpleAnnotatedAlias.class.getName());
    }
 }
\ No newline at end of file

Copied: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/test/BuilderBeansUnitTestCase.java (from rev 77001, projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/test/AnnotatedBeansUnitTestCase.java)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/test/BuilderBeansUnitTestCase.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/test/BuilderBeansUnitTestCase.java	2008-08-13 08:41:38 UTC (rev 77003)
@@ -0,0 +1,110 @@
+/*
+* 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.deployers.vfs.deployer.bean.test;
+
+import java.lang.annotation.Annotation;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.jboss.beans.metadata.api.annotations.Aliases;
+import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.dependency.spi.Controller;
+import org.jboss.kernel.plugins.bootstrap.basic.KernelConstants;
+import org.jboss.test.deployers.vfs.deployer.bean.support.SimpleAliasTester;
+import org.jboss.test.deployers.vfs.deployer.bean.support.SimpleConstructorTester;
+import org.jboss.test.deployers.vfs.deployer.bean.support.SimpleInjectionTester;
+import org.jboss.test.deployers.vfs.deployer.bean.support.SimpleStartTester;
+
+/**
+ * BuilderBeansUnitTestCase.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BuilderBeansUnitTestCase extends AbstractAnnotationBeansTest
+{
+   public static Test suite()
+   {
+      return new TestSuite(BuilderBeansUnitTestCase.class);
+   }
+
+   public BuilderBeansUnitTestCase(String name) throws Throwable
+   {
+      super(name);
+   }
+
+   protected BeanMetaDataFactory getConstructorTester()
+   {
+      BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("Constructor", SimpleConstructorTester.class.getName());
+      builder.addConstructorParameter(Controller.class.getName(), builder.createInject(KernelConstants.KERNEL_CONTROLLER_NAME));
+      return builder.getBeanMetaDataFactory();
+   }
+
+   protected BeanMetaDataFactory getInjectionTester()
+   {
+      BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("Injection", SimpleInjectionTester.class.getName());
+      builder.addPropertyMetaData("controller", builder.createInject(KernelConstants.KERNEL_CONTROLLER_NAME));
+      return builder.getBeanMetaDataFactory();
+   }
+
+   protected BeanMetaDataFactory getStartTester()
+   {
+      BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("Start", SimpleStartTester.class.getName());
+      builder.setStart("onStart").addStartParameter(Controller.class.getName(), builder.createInject(KernelConstants.KERNEL_CONTROLLER_NAME));      
+      return builder.getBeanMetaDataFactory();
+   }
+
+   protected BeanMetaDataFactory getAliasTester()
+   {
+      BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("SomeRandomName", SimpleAliasTester.class.getName());
+      builder.setFactoryMethod("factory");
+      builder.addPropertyMetaData("controller", builder.createInject(KernelConstants.KERNEL_CONTROLLER_NAME));
+      builder.addAnnotation(new AliasesImpl("Alias"));
+      return builder.getBeanMetaDataFactory();
+   }
+
+   @SuppressWarnings({"ClassExplicitlyAnnotation"})
+   private class AliasesImpl implements Aliases
+   {
+      private String[] value;
+
+      private AliasesImpl(String... aliases)
+      {
+         this.value = aliases;
+      }
+
+      public String[] value()
+      {
+         return value; 
+      }
+
+      public boolean replace()
+      {
+         return false;
+      }
+
+      public Class<? extends Annotation> annotationType()
+      {
+         return Aliases.class;
+      }
+   }
+}
\ No newline at end of file




More information about the jboss-cvs-commits mailing list