[jboss-cvs] JBossAS SVN: r75299 - in projects/microcontainer/trunk: kernel/src/resources/tests/org/jboss/test/kernel/deployment/test and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jul 2 05:28:58 EDT 2008
Author: alesj
Date: 2008-07-02 05:28:58 -0400 (Wed, 02 Jul 2008)
New Revision: 75299
Added:
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/test/ScopingAliasAPITestCase.xml
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/ScopingAliasAPITestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/ScopingTestAPIDelegate.java
Modified:
projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractController.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/ScopingAliasTestCase.java
Log:
[JBMICROCONT-309]; add api copy of scoping alias test.
Modified: projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractController.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractController.java 2008-07-02 08:18:05 UTC (rev 75298)
+++ projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractController.java 2008-07-02 09:28:58 UTC (rev 75299)
@@ -1644,7 +1644,7 @@
if (allContexts.containsKey(name) == false)
allContexts.put(name, context);
else
- throw new IllegalStateException("Unable to register context" + context.toShortString() + " name already exists: " + name);
+ throw new IllegalStateException("Unable to register context " + context.toShortString() + ", name already exists: " + name);
}
/**
@@ -1698,11 +1698,13 @@
if (jmxOriginal != null)
original = jmxOriginal;
+ // get the context's controller - not the one we registered with
+ AbstractController controller = (AbstractController)context.getController();
lockWrite();
try
{
- ControllerContext lookup = getRegisteredControllerContext(original, true);
- registerControllerContext(alias, lookup);
+ ControllerContext lookup = controller.getRegisteredControllerContext(original, true);
+ controller.registerControllerContext(alias, lookup);
if (log.isTraceEnabled())
log.trace("Added alias " + alias + " for context " + context);
}
@@ -1722,7 +1724,9 @@
if (jmxAlias != null)
alias = jmxAlias;
- unregisterControllerContext(alias);
+ // get the context's controller - not the one we registered with
+ AbstractController controller = (AbstractController)context.getController();
+ controller.unregisterControllerContext(alias);
if (log.isTraceEnabled())
log.trace("Removed alias " + alias);
}
Copied: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/test/ScopingAliasAPITestCase.xml (from rev 75214, projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/test/ScopingAliasTestCase.xml)
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/test/ScopingAliasAPITestCase.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/test/ScopingAliasAPITestCase.xml 2008-07-02 09:28:58 UTC (rev 75299)
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="main" class="org.jboss.test.kernel.deployment.support.SimpleObjectWithBean">
+ <property name="simpleBean"><inject bean="simple"/></property>
+ </bean>
+
+ <bean name="deploy1" class="org.jboss.test.kernel.deployment.support.SimpleObjectWithBean">
+ <annotation>@org.jboss.metadata.plugins.scope.ApplicationScope("testApp")</annotation>
+ <annotation>@org.jboss.metadata.plugins.scope.DeploymentScope("deployment1")</annotation>
+ <property name="simpleBean"><inject bean="simple"/></property>
+ </bean>
+
+ <bean name="deploy2" class="org.jboss.test.kernel.deployment.support.SimpleObjectWithBean">
+ <annotation>@org.jboss.metadata.plugins.scope.ApplicationScope("testApp")</annotation>
+ <annotation>@org.jboss.metadata.plugins.scope.DeploymentScope("deployment2")</annotation>
+ <property name="simpleBean"><inject bean="simple"/></property>
+ </bean>
+
+ <bean name="deploy3" class="org.jboss.test.kernel.deployment.support.SimpleObjectWithBean">
+ <annotation>@org.jboss.metadata.plugins.scope.ApplicationScope("testApp")</annotation>
+ <annotation>@org.jboss.metadata.plugins.scope.DeploymentScope("deployment3")</annotation>
+ <property name="simpleBean"><inject bean="simple"/></property>
+ </bean>
+
+ <bean name="simple1" class="org.jboss.test.kernel.deployment.support.SimpleBeanImpl">
+ <annotation>@org.jboss.metadata.plugins.scope.ApplicationScope("testApp")</annotation>
+ <annotation>@org.jboss.metadata.plugins.scope.DeploymentScope("deployment1")</annotation>
+ <constructor>
+ <parameter>deployment1</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="simple3" class="org.jboss.test.kernel.deployment.support.SimpleBeanImpl">
+ <annotation>@org.jboss.metadata.plugins.scope.ApplicationScope("testApp")</annotation>
+ <annotation>@org.jboss.metadata.plugins.scope.DeploymentScope("deployment3")</annotation>
+ <constructor>
+ <parameter>deployment3</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="simple-main" class="org.jboss.test.kernel.deployment.support.SimpleBeanImpl">
+ <constructor>
+ <parameter>main</parameter>
+ </constructor>
+ </bean>
+
+</deployment>
Copied: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/ScopingAliasAPITestCase.java (from rev 75212, projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/ScopingAliasTestCase.java)
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/ScopingAliasAPITestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/ScopingAliasAPITestCase.java 2008-07-02 09:28:58 UTC (rev 75299)
@@ -0,0 +1,131 @@
+/*
+* 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.dependency.plugins.ScopedAliasControllerContext;
+import org.jboss.dependency.spi.Controller;
+import org.jboss.metadata.spi.scope.CommonLevels;
+import org.jboss.metadata.spi.scope.Scope;
+import org.jboss.metadata.spi.scope.ScopeKey;
+import org.jboss.test.kernel.deployment.support.SimpleBean;
+import org.jboss.test.kernel.deployment.support.SimpleObjectWithBean;
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * Scoping alias API tests.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ScopingAliasAPITestCase extends ScopingDeploymentTest
+{
+ public ScopingAliasAPITestCase(String name) throws Throwable
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(ScopingAliasAPITestCase.class);
+ }
+
+ /**
+ * Default setup with security manager enabled
+ *
+ * @param clazz the class
+ * @return the delegate
+ * @throws Exception for any error
+ */
+ public static AbstractTestDelegate getDelegate(Class<?> clazz) throws Exception
+ {
+ AbstractTestDelegate delegate = new ScopingTestAPIDelegate(clazz);
+ delegate.enableSecurity = true;
+ return delegate;
+ }
+
+ protected void afterSetUp() throws Exception
+ {
+ try
+ {
+ Controller controller = ((ScopingTestAPIDelegate)getDelegate()).getController();
+
+ ScopeKey sk1 = new ScopeKey(new Scope[]{new Scope(CommonLevels.DEPLOYMENT, "deployment1"), new Scope(CommonLevels.APPLICATION, "testApp")});
+ ScopedAliasControllerContext.addAlias("simple", "simple1", sk1, controller);
+
+ ScopeKey sk3 = new ScopeKey(new Scope[]{new Scope(CommonLevels.DEPLOYMENT, "deployment3"), new Scope(CommonLevels.APPLICATION, "testApp")});
+ ScopedAliasControllerContext.addAlias("simple", "simple3", sk3, controller);
+
+ controller.addAlias("simple", "simple-main");
+ }
+ catch (Throwable t)
+ {
+ throw new Exception(t);
+ }
+
+ super.afterSetUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ Controller controller = ((ScopingTestAPIDelegate)getDelegate()).getController();
+
+ controller.removeAlias("simple");
+
+ ScopeKey sk1 = new ScopeKey(new Scope[]{new Scope(CommonLevels.DEPLOYMENT, "deployment1"), new Scope(CommonLevels.APPLICATION, "testApp")});
+ ScopedAliasControllerContext.removeAlias("simple", sk1, controller);
+
+ ScopeKey sk3 = new ScopeKey(new Scope[]{new Scope(CommonLevels.DEPLOYMENT, "deployment3"), new Scope(CommonLevels.APPLICATION, "testApp")});
+ ScopedAliasControllerContext.removeAlias("simple", sk3, controller);
+
+ super.tearDown();
+ }
+
+ public void testAliasInMainController() throws Throwable
+ {
+ checkBean("main", "main");
+ }
+
+ public void testAliasInOwnScope() throws Throwable
+ {
+ checkBean("deploy1", "deployment1");
+ }
+
+ public void testAliasInParentScope() throws Throwable
+ {
+ checkBean("deploy2", "main");
+ }
+
+ public void testAliasInOwnScope2() throws Throwable
+ {
+ checkBean("deploy3", "deployment3");
+ }
+
+ private void checkBean(String bean, String ctor)
+ {
+ SimpleObjectWithBean deploy = (SimpleObjectWithBean) getBean(bean);
+ assertNotNull(deploy);
+ SimpleBean simple = deploy.getSimpleBean();
+ assertNotNull(simple);
+ assertEquals(ctor, simple.getConstructorString());
+ }
+}
\ No newline at end of file
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/ScopingAliasTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/ScopingAliasTestCase.java 2008-07-02 08:18:05 UTC (rev 75298)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/ScopingAliasTestCase.java 2008-07-02 09:28:58 UTC (rev 75299)
@@ -27,6 +27,7 @@
import org.jboss.test.kernel.deployment.support.SimpleObjectWithBean;
/**
+ * Scoping alias tests.
*
* @author <a href="mailto:kabir.khan at jboss.com">Kabir Khan</a>
*/
@@ -42,9 +43,6 @@
return suite(ScopingAliasTestCase.class);
}
-
- // ---- tests
-
public void testAliasInMainController() throws Throwable
{
checkBean("main", "main");
Copied: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/ScopingTestAPIDelegate.java (from rev 75212, projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/ScopingTestDelegate.java)
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/ScopingTestAPIDelegate.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/ScopingTestAPIDelegate.java 2008-07-02 09:28:58 UTC (rev 75299)
@@ -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.kernel.deployment.test;
+
+import org.jboss.dependency.spi.Controller;
+
+/**
+ * Scoping Deployment API Test Delegate.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ScopingTestAPIDelegate extends ScopingTestDelegate
+{
+ public ScopingTestAPIDelegate(Class<?> clazz) throws Exception
+ {
+ super(clazz);
+ }
+
+ Controller getController()
+ {
+ return kernel.getController();
+ }
+}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list