[jboss-cvs] JBossAS SVN: r104813 - in projects/jboss-deployers/trunk: deployers-vfs/src/main/java/org/jboss/deployers/vfs/deployer/kernel and 7 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri May 14 16:44:58 EDT 2010
Author: alesj
Date: 2010-05-14 16:44:57 -0400 (Fri, 14 May 2010)
New Revision: 104813
Added:
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/dependency/support/FDTest.java
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/dependency/test/FromDeploymentTestCase.java
projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/dependency/fd/
projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/dependency/fd/META-INF/
projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/dependency/fd/META-INF/jboss-beans.xml
projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/org/jboss/test/deployers/vfs/dependency/test/FromDeploymentTestCase.xml
Modified:
projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/metadata/FromDeployment.java
projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/deployer/kernel/BeanMetaDataDeployer.java
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/dependency/DependencyTestSuite.java
Log:
[JBDEPLOY-259]; test FromDeployment.
Modified: projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/metadata/FromDeployment.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/metadata/FromDeployment.java 2010-05-14 19:56:06 UTC (rev 104812)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/metadata/FromDeployment.java 2010-05-14 20:44:57 UTC (rev 104813)
@@ -35,7 +35,7 @@
DEPLOYMENT(new DefaultFromDeploymentDelegate()),
SIMPLE_NAME(new SimpleNameFromDeploymentDelegate()),
TOP_DEPLOYMENT(new TopDeploymentDelegate()),
- TOP_DEPLOYMENT_SIMPLE_NAME(new TopSimpleNameDeploymentDelegate());
+ TOP_SIMPLE_NAME(new TopSimpleNameDeploymentDelegate());
private FromDeploymentDelegate delegate;
Modified: projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/deployer/kernel/BeanMetaDataDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/deployer/kernel/BeanMetaDataDeployer.java 2010-05-14 19:56:06 UTC (rev 104812)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/deployer/kernel/BeanMetaDataDeployer.java 2010-05-14 20:44:57 UTC (rev 104813)
@@ -35,8 +35,8 @@
import org.jboss.beans.metadata.spi.ClassLoaderMetaData;
import org.jboss.beans.metadata.spi.ValueMetaData;
import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerContext;
import org.jboss.dependency.spi.ScopeInfo;
-import org.jboss.dependency.spi.ControllerContext;
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
import org.jboss.deployers.structure.spi.DeploymentUnit;
@@ -177,11 +177,13 @@
try
{
+ // move this before install, so FromDeployment can access it
+ putContext(context, unit.getParent()); // we're a component, use parent
controller.install(context);
- putContext(context, unit.getParent()); // we're a component, use parent
}
catch (Throwable t)
{
+ removeContext(context, unit.getParent());
throw DeploymentException.rethrowAsDeploymentException("Error deploying: " + deployment.getName(), t);
}
}
Modified: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/dependency/DependencyTestSuite.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/dependency/DependencyTestSuite.java 2010-05-14 19:56:06 UTC (rev 104812)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/dependency/DependencyTestSuite.java 2010-05-14 20:44:57 UTC (rev 104813)
@@ -21,10 +21,12 @@
*/
package org.jboss.test.deployers.vfs.dependency;
+import org.jboss.test.deployers.vfs.dependency.test.DependenciesTestCase;
+import org.jboss.test.deployers.vfs.dependency.test.FromDeploymentTestCase;
+
import junit.framework.Test;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
-import org.jboss.test.deployers.vfs.dependency.test.DependenciesTestCase;
/**
* DependencyTestSuite.
@@ -43,6 +45,7 @@
TestSuite suite = new TestSuite("VFS Dependency Scanning Tests");
suite.addTest(DependenciesTestCase.suite());
+ suite.addTest(FromDeploymentTestCase.suite());
return suite;
}
Copied: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/dependency/support/FDTest.java (from rev 104761, projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/dependency/support/MockTM.java)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/dependency/support/FDTest.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/dependency/support/FDTest.java 2010-05-14 20:44:57 UTC (rev 104813)
@@ -0,0 +1,53 @@
+/*
+ * 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.deployers.vfs.dependency.support;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class FDTest
+{
+ private String appName;
+ private DeploymentUnit unit;
+
+ public String getAppName()
+ {
+ return appName;
+ }
+
+ public void setAppName(String appName)
+ {
+ this.appName = appName;
+ }
+
+ public DeploymentUnit getUnit()
+ {
+ return unit;
+ }
+
+ public void setUnit(DeploymentUnit unit)
+ {
+ this.unit = unit;
+ }
+}
\ No newline at end of file
Added: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/dependency/test/FromDeploymentTestCase.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/dependency/test/FromDeploymentTestCase.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/dependency/test/FromDeploymentTestCase.java 2010-05-14 20:44:57 UTC (rev 104813)
@@ -0,0 +1,99 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.deployers.vfs.dependency.test;
+
+import java.lang.reflect.Method;
+
+import org.jboss.deployers.plugins.metadata.FromDeploymentValueMetaData;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.test.deployers.BootstrapDeployersTest;
+import org.jboss.test.deployers.support.AssembledDirectory;
+import org.jboss.test.deployers.vfs.dependency.support.FDTest;
+import org.jboss.vfs.VFS;
+import org.jboss.vfs.VirtualFile;
+import org.jboss.xb.util.JBossXBHelper;
+
+import junit.framework.Test;
+
+/**
+ * FromDeploymentTestCase.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class FromDeploymentTestCase extends BootstrapDeployersTest
+{
+ public FromDeploymentTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(FromDeploymentTestCase.class);
+ }
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ JBossXBHelper.addClassBinding("urn:jboss:bean-deployer:deployment:2.0", FromDeploymentValueMetaData.class);
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ JBossXBHelper.removeClassBinding("urn:jboss:bean-deployer:deployment:2.0");
+ super.tearDown();
+ }
+
+ public void testBasic() throws Throwable
+ {
+ String appName = "fdAppName.jar";
+ VirtualFile file = VFS.getChild(appName);
+ AssembledDirectory root = createAssembledDirectory(file);
+ root.addPackage(FDTest.class).addPath("/dependency/fd");
+
+ DeploymentUnit unit = assertDeploy(file);
+ try
+ {
+ Object test1 = assertBean("Test1", Object.class);
+ assertFromDeployment(test1, unit, appName);
+
+ Object test2 = assertBean("Test2", Object.class);
+ assertFromDeployment(test2, unit, appName);
+ }
+ finally
+ {
+ undeploy(unit);
+ }
+ }
+
+ protected void assertFromDeployment(Object test, DeploymentUnit unit, String appName) throws Exception
+ {
+ Class<?> clazz = test.getClass();
+ Method u = clazz.getMethod("getUnit");
+ assertSame(unit, u.invoke(test));
+ Method m = clazz.getMethod("getAppName");
+ assertEquals(appName, m.invoke(test));
+ }
+}
Added: projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/dependency/fd/META-INF/jboss-beans.xml
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/dependency/fd/META-INF/jboss-beans.xml (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/dependency/fd/META-INF/jboss-beans.xml 2010-05-14 20:44:57 UTC (rev 104813)
@@ -0,0 +1,13 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="Test1" class="org.jboss.test.deployers.vfs.dependency.support.FDTest">
+ <property name="unit"><from-deployment xmlns="urn:jboss:bean-deployer:deployment:2.0" type="deployment"/></property>
+ <property name="appName"><from-deployment xmlns="urn:jboss:bean-deployer:deployment:2.0" type="simple_name"/></property>
+ </bean>
+
+ <bean name="Test2" class="org.jboss.test.deployers.vfs.dependency.support.FDTest">
+ <property name="unit"><from-deployment xmlns="urn:jboss:bean-deployer:deployment:2.0" type="top_deployment"/></property>
+ <property name="appName"><from-deployment xmlns="urn:jboss:bean-deployer:deployment:2.0" type="top_simple_name"/></property>
+ </bean>
+
+</deployment>
Copied: projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/org/jboss/test/deployers/vfs/dependency/test/FromDeploymentTestCase.xml (from rev 104761, projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/org/jboss/test/deployers/vfs/dependency/test/DependenciesTestCase.xml)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/org/jboss/test/deployers/vfs/dependency/test/FromDeploymentTestCase.xml (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/org/jboss/test/deployers/vfs/dependency/test/FromDeploymentTestCase.xml 2010-05-14 20:44:57 UTC (rev 104813)
@@ -0,0 +1,12 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="DURegistry" class="org.jboss.deployers.structure.spi.helpers.AbstractDeploymentRegistry">
+ <install bean="BeanMetaDataDeployer" method="setDeploymentRegistry">
+ <parameter><this/></parameter>
+ </install>
+ <uninstall bean="BeanMetaDataDeployer" method="setDeploymentRegistry">
+ <parameter><null/></parameter>
+ </uninstall>
+ </bean>
+
+</deployment>
More information about the jboss-cvs-commits
mailing list