[jboss-cvs] JBossAS SVN: r61417 - in projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer: test and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Mar 18 23:16:28 EDT 2007
Author: scott.stark at jboss.org
Date: 2007-03-18 23:16:28 -0400 (Sun, 18 Mar 2007)
New Revision: 61417
Added:
projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/support/TestDeployment.java
projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/support/TestDeploymentDeployer.java
projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/support/TestMetaData.java
projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/test/MultipleComponentTypeUnitTestCase.java
Log:
JBMICROCONT-159, Test of deployments with multiple deployment types that map to multiple components
Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/support/TestDeployment.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/support/TestDeployment.java (rev 0)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/support/TestDeployment.java 2007-03-19 03:16:28 UTC (rev 61417)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * 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.deployer.support;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class TestDeployment
+{
+ ArrayList<TestMetaData> beans = new ArrayList<TestMetaData>();
+
+ public void addBean(TestMetaData data)
+ {
+ beans.add(data);
+ }
+
+ public List<TestMetaData> getBeans()
+ {
+ return beans;
+ }
+}
Property changes on: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/support/TestDeployment.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/support/TestDeploymentDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/support/TestDeploymentDeployer.java (rev 0)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/support/TestDeploymentDeployer.java 2007-03-19 03:16:28 UTC (rev 61417)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * 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.deployer.support;
+
+import java.util.List;
+
+import org.jboss.deployers.plugins.deployers.helpers.AbstractComponentDeployer;
+import org.jboss.deployers.plugins.deployers.helpers.SimpleDeploymentVisitor;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+
+public class TestDeploymentDeployer
+ extends AbstractComponentDeployer<TestDeployment, TestMetaData>
+{
+
+ public TestDeploymentDeployer()
+ {
+ setDeploymentVisitor(new TestDeploymentVisitor());
+ setComponentVisitor(new TestMetaDataVisitor());
+ }
+
+ protected static void addTestComponent(DeploymentUnit unit, TestMetaData test)
+ {
+ DeploymentUnit component = unit.addComponent(test.getName());
+ component.addAttachment(TestMetaData.class.getName(), test);
+ }
+
+ protected static void removeTestComponent(DeploymentUnit unit, TestMetaData test)
+ {
+ unit.removeComponent(test.getName());
+ }
+
+ /**
+ * TestDeploymentVisitor.
+ */
+ public class TestDeploymentVisitor implements SimpleDeploymentVisitor<TestDeployment>
+ {
+ public Class<TestDeployment> getVisitorType()
+ {
+ return TestDeployment.class;
+ }
+
+ public void deploy(DeploymentUnit unit, TestDeployment deployment) throws DeploymentException
+ {
+ try
+ {
+ List<TestMetaData> tests = deployment.getBeans();
+ if (tests == null || tests.isEmpty())
+ return;
+
+ for (TestMetaData test : tests)
+ addTestComponent(unit, test);
+ }
+ catch (Throwable t)
+ {
+ throw DeploymentException.rethrowAsDeploymentException("Error deploying: " + deployment, t);
+ }
+ }
+
+ public void undeploy(DeploymentUnit unit, TestDeployment deployment)
+ {
+ List<TestMetaData> tests = deployment.getBeans();
+ if (tests == null)
+ return;
+
+ for (TestMetaData test : tests)
+ {
+ unit.removeComponent(test.getName());
+ }
+ }
+ }
+
+ /**
+ * TestMetaDataVisitor.
+ */
+ public static class TestMetaDataVisitor implements SimpleDeploymentVisitor<TestMetaData>
+ {
+ public Class<TestMetaData> getVisitorType()
+ {
+ return TestMetaData.class;
+ }
+
+ public void deploy(DeploymentUnit unit, TestMetaData deployment) throws DeploymentException
+ {
+ addTestComponent(unit, deployment);
+ }
+
+ public void undeploy(DeploymentUnit unit, TestMetaData deployment)
+ {
+ removeTestComponent(unit, deployment);
+ }
+ }
+
+
+}
Property changes on: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/support/TestDeploymentDeployer.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/support/TestMetaData.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/support/TestMetaData.java (rev 0)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/support/TestMetaData.java 2007-03-19 03:16:28 UTC (rev 61417)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * 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.deployer.support;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class TestMetaData
+{
+ private String name;
+
+ public TestMetaData(String name)
+ {
+ this.name = name;
+ }
+ public String getName()
+ {
+ return name;
+ }
+}
Property changes on: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/support/TestMetaData.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/test/MultipleComponentTypeUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/test/MultipleComponentTypeUnitTestCase.java (rev 0)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/test/MultipleComponentTypeUnitTestCase.java 2007-03-19 03:16:28 UTC (rev 61417)
@@ -0,0 +1,119 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, 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.deployer.test;
+
+import java.util.Collections;
+
+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.deployers.plugins.deployers.kernel.BeanMetaDataDeployer;
+import org.jboss.deployers.plugins.deployers.kernel.KernelDeploymentDeployer;
+import org.jboss.deployers.plugins.deployment.MainDeployerImpl;
+import org.jboss.deployers.spi.deployment.MainDeployer;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.deployers.spi.structure.StructureDetermined;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
+import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.test.deployers.BaseDeployersTest;
+import org.jboss.test.deployers.bean.support.Simple;
+import org.jboss.test.deployers.deployer.support.TestDeployment;
+import org.jboss.test.deployers.deployer.support.TestDeploymentDeployer;
+import org.jboss.test.deployers.deployer.support.TestMetaData;
+
+/**
+ * Test of deployments with multiple deployment types that map to
+ * multiple components.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class MultipleComponentTypeUnitTestCase extends BaseDeployersTest
+{
+ private MainDeployerImpl mainDeployer;
+ private KernelController controller;
+
+ public static Test suite()
+ {
+ return new TestSuite(MultipleComponentTypeUnitTestCase.class);
+ }
+
+ public MultipleComponentTypeUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ try
+ {
+ BasicBootstrap bootstrap = new BasicBootstrap();
+ bootstrap.run();
+ Kernel kernel = bootstrap.getKernel();
+ controller = kernel.getController();
+
+ mainDeployer = new MainDeployerImpl();
+
+ TestDeploymentDeployer testDeployer = new TestDeploymentDeployer();
+ KernelDeploymentDeployer kernelDeploymentDeployer = new KernelDeploymentDeployer();
+ BeanMetaDataDeployer beanMetaDataDeployer = new BeanMetaDataDeployer(kernel);
+ mainDeployer.addDeployer(testDeployer);
+ mainDeployer.addDeployer(kernelDeploymentDeployer);
+ mainDeployer.addDeployer(beanMetaDataDeployer);
+ }
+ catch (Throwable t)
+ {
+ throw new RuntimeException(t);
+ }
+ }
+
+ public void testDeploy() throws Exception
+ {
+ MainDeployer main = mainDeployer;
+
+ DeploymentContext context = createSimpleDeployment("deploy");
+ main.addDeploymentContext(context);
+ // Add a kernel deployment
+ context.setStructureDetermined(StructureDetermined.PREDETERMINED);
+
+ AbstractKernelDeployment deployment = new AbstractKernelDeployment();
+ deployment.setName("KernelDeployerTest");
+
+ BeanMetaDataFactory metaData = new AbstractBeanMetaData("MCBean1", Simple.class.getName());
+ deployment.setBeanFactories(Collections.singletonList(metaData));
+
+ context.getPredeterminedManagedObjects().addAttachment("KernelDeployerTest", deployment);
+ // Add a TestDeploymentDeployer
+ TestDeployment deployment2 = new TestDeployment();
+ deployment2.addBean(new TestMetaData("TestBean1"));
+ context.getTransientAttachments().addAttachment(TestDeployment.class, deployment2);
+ main.process();
+
+ assertNotNull(controller.getInstalledContext("MCBean1"));
+ }
+
+}
Property changes on: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/test/MultipleComponentTypeUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
More information about the jboss-cvs-commits
mailing list