[jboss-cvs] JBossAS SVN: r80577 - in projects/jboss-deployers/trunk/deployers-vfs/src/test/java/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
Thu Nov 6 05:01:56 EST 2008
Author: alesj
Date: 2008-11-06 05:01:55 -0500 (Thu, 06 Nov 2008)
New Revision: 80577
Added:
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/bean/support/DefaultXPCResolver.java
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/bean/support/PUDeployment.java
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/bean/support/XPCResolver.java
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/bean/test/AutowireAnnotationBeansTestCase.java
Modified:
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/bean/BeanDeployerTestSuite.java
Log:
Add PUD + XPC mock test - JPA/EJB issue.
Modified: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/bean/BeanDeployerTestSuite.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/bean/BeanDeployerTestSuite.java 2008-11-06 08:58:20 UTC (rev 80576)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/bean/BeanDeployerTestSuite.java 2008-11-06 10:01:55 UTC (rev 80577)
@@ -34,6 +34,7 @@
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.AutowireAnnotationBeansTestCase;
/**
* BeanDeployerTestSuite.
@@ -63,6 +64,7 @@
suite.addTest(KernelScopeUnitTestCase.suite());
suite.addTest(AnnotatedBeansUnitTestCase.suite());
suite.addTest(BuilderBeansUnitTestCase.suite());
+ suite.addTest(AutowireAnnotationBeansTestCase.suite());
return suite;
}
Added: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/bean/support/DefaultXPCResolver.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/bean/support/DefaultXPCResolver.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/bean/support/DefaultXPCResolver.java 2008-11-06 10:01:55 UTC (rev 80577)
@@ -0,0 +1,33 @@
+/*
+* 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;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class DefaultXPCResolver implements XPCResolver
+{
+ public String getName()
+ {
+ return "Default";
+ }
+}
\ No newline at end of file
Added: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/bean/support/PUDeployment.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/bean/support/PUDeployment.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/bean/support/PUDeployment.java 2008-11-06 10:01:55 UTC (rev 80577)
@@ -0,0 +1,43 @@
+/*
+* 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.beans.metadata.api.annotations.Inject;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PUDeployment
+{
+ private XPCResolver resolver;
+
+ public XPCResolver getResolver()
+ {
+ return resolver;
+ }
+
+ @Inject
+ public void setResolver(XPCResolver resolver)
+ {
+ this.resolver = resolver;
+ }
+}
Added: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/bean/support/XPCResolver.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/bean/support/XPCResolver.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/bean/support/XPCResolver.java 2008-11-06 10:01:55 UTC (rev 80577)
@@ -0,0 +1,30 @@
+/*
+* 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;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface XPCResolver
+{
+ String getName();
+}
\ No newline at end of file
Copied: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/bean/test/AutowireAnnotationBeansTestCase.java (from rev 80551, projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/bean/test/AbstractAnnotationBeansTest.java)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/bean/test/AutowireAnnotationBeansTestCase.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/bean/test/AutowireAnnotationBeansTestCase.java 2008-11-06 10:01:55 UTC (rev 80577)
@@ -0,0 +1,188 @@
+/*
+* 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 junit.framework.Test;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractConstructorMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
+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.support.TCCLClassLoaderDeployer;
+import org.jboss.test.deployers.vfs.deployer.AbstractDeployerUnitTest;
+import org.jboss.test.deployers.vfs.deployer.bean.support.DefaultXPCResolver;
+import org.jboss.test.deployers.vfs.deployer.bean.support.PUDeployment;
+
+/**
+ * AutowireAnnotationBeansTestCase.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AutowireAnnotationBeansTestCase extends AbstractDeployerUnitTest
+{
+ public AutowireAnnotationBeansTestCase(String name) throws Throwable
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(AutowireAnnotationBeansTestCase.class);
+ }
+
+ protected void addDeployers(Kernel kernel)
+ {
+ TCCLClassLoaderDeployer tcclDeployer = new TCCLClassLoaderDeployer();
+ KernelDeploymentDeployer kernelDeploymentDeployer = new KernelDeploymentDeployer();
+ BeanMetaDataDeployer beanMetaDataDeployer = new BeanMetaDataDeployer(kernel.getController());
+ addDeployer(main, tcclDeployer);
+ addDeployer(main, kernelDeploymentDeployer);
+ addDeployer(main, beanMetaDataDeployer);
+ }
+
+ public void testAutowiredBeans() throws Exception
+ {
+ Deployment context = createSimpleDeployment("KernelDeployerTest1");
+
+ AbstractKernelDeployment deployment = new AbstractKernelDeployment();
+ deployment.setName("KernelDeployerTest1");
+ BeanMetaDataFactory md1 = new AbstractBeanMetaData("PUD", PUDeployment.class.getName());
+ BeanMetaDataFactory md2 = new AbstractBeanMetaData("XPC", DefaultXPCResolver.class.getName());
+ deployment.setBeanFactories(Arrays.asList(md1, md2));
+ MutableAttachments attachments = (MutableAttachments) context.getPredeterminedManagedObjects();
+ attachments.addAttachment("KernelDeployerTest1", deployment);
+
+ assertDeploy(context);
+ try
+ {
+ ControllerContext pud = controller.getInstalledContext("PUD");
+ assertNotNull(pud);
+ }
+ finally
+ {
+ assertUndeploy(context);
+ }
+
+ assertNull(controller.getContext("PUD", null));
+ assertNull(controller.getContext("XPC", null));
+ }
+
+ public void testMissingAutowireDependency() throws Exception
+ {
+ Deployment context = createSimpleDeployment("KernelDeployerTest2");
+
+ AbstractKernelDeployment deployment = new AbstractKernelDeployment();
+ deployment.setName("KernelDeployerTest2");
+ BeanMetaDataFactory md1 = new AbstractBeanMetaData("PUD", PUDeployment.class.getName());
+ deployment.setBeanFactories(Arrays.asList(md1));
+ MutableAttachments attachments = (MutableAttachments) context.getPredeterminedManagedObjects();
+ attachments.addAttachment("KernelDeployerTest2", deployment);
+
+ assertDeploy(context);
+ try
+ {
+ ControllerContext pud = controller.getContext("PUD", null);
+ assertNotNull(pud);
+ assertEquals(ControllerState.INSTANTIATED, pud.getState());
+ }
+ finally
+ {
+ assertUndeploy(context);
+ }
+
+ assertNull(controller.getContext("PUD", null));
+ }
+
+ public void testDependencyOnExistingTarget() throws Exception
+ {
+ Deployment context = createSimpleDeployment("KernelDeployerTest3");
+
+ AbstractKernelDeployment deployment = new AbstractKernelDeployment();
+ deployment.setName("KernelDeployerTest3");
+ PUDeployment bean = new PUDeployment();
+ AbstractBeanMetaData md1 = new AbstractBeanMetaData("PUD", PUDeployment.class.getName());
+ AbstractConstructorMetaData acmd = new AbstractConstructorMetaData();
+ acmd.setValueObject(bean);
+ md1.setConstructor(acmd);
+ BeanMetaDataFactory md2 = new AbstractBeanMetaData("XPC", DefaultXPCResolver.class.getName());
+ deployment.setBeanFactories(Arrays.asList(md1, md2));
+ MutableAttachments attachments = (MutableAttachments) context.getPredeterminedManagedObjects();
+ attachments.addAttachment("KernelDeployerTest3", deployment);
+
+ assertDeploy(context);
+ try
+ {
+ ControllerContext pud = controller.getInstalledContext("PUD");
+ assertNotNull(pud);
+ ControllerContext xpc = controller.getInstalledContext("XPC");
+ assertNotNull(xpc);
+ assertSame(bean.getResolver(), xpc.getTarget());
+ }
+ finally
+ {
+ assertUndeploy(context);
+ }
+
+ assertNull(controller.getContext("PUD", null));
+ assertNull(controller.getContext("XPC", null));
+ }
+
+ public void testExistingTargetWithMissingDependency() throws Exception
+ {
+ Deployment context = createSimpleDeployment("KernelDeployerTest4");
+
+ AbstractKernelDeployment deployment = new AbstractKernelDeployment();
+ deployment.setName("KernelDeployerTest4");
+ PUDeployment bean = new PUDeployment();
+ AbstractBeanMetaData md1 = new AbstractBeanMetaData("PUD", PUDeployment.class.getName());
+ AbstractConstructorMetaData acmd = new AbstractConstructorMetaData();
+ acmd.setValueObject(bean);
+ md1.setConstructor(acmd);
+ deployment.setBeanFactories(Arrays.asList((BeanMetaDataFactory)md1));
+ MutableAttachments attachments = (MutableAttachments) context.getPredeterminedManagedObjects();
+ attachments.addAttachment("KernelDeployerTest4", deployment);
+
+ assertDeploy(context);
+ try
+ {
+ ControllerContext pud = controller.getContext("PUD", null);
+ assertNotNull(pud);
+ assertSame(bean, pud.getTarget());
+ assertNull(bean.getResolver());
+ assertEquals(ControllerState.INSTANTIATED, pud.getState());
+ }
+ finally
+ {
+ assertUndeploy(context);
+ }
+
+ assertNull(controller.getContext("PUD", null));
+ }
+}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list