[jboss-cvs] JBossAS SVN: r75535 - in projects/microcontainer/trunk: kernel/src/main/org/jboss/beans/metadata/plugins and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jul 9 05:40:21 EDT 2008


Author: alesj
Date: 2008-07-09 05:40:20 -0400 (Wed, 09 Jul 2008)
New Revision: 75535

Added:
   projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/graph/HierarchyLookupStrategy.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/search/AbstractSearchAnnotationSupportTest.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/search/OrderSearchAnnotationSupportTestCase.java
Modified:
   projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/graph/DepthLookupStrategy.java
   projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/graph/LeavesFirstLookupStrategy.java
   projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/graph/LocalLookupStrategy.java
   projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/graph/WidthLookupStrategy.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractDependencyValueMetaData.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/SearchPropertyAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/search/BasicSearchAnnotationSupportTestCase.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/search/SearchTestSuite.java
Log:
Add order search test.

Modified: projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/graph/DepthLookupStrategy.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/graph/DepthLookupStrategy.java	2008-07-09 09:15:57 UTC (rev 75534)
+++ projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/graph/DepthLookupStrategy.java	2008-07-09 09:40:20 UTC (rev 75535)
@@ -32,10 +32,8 @@
  *
  * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
  */
-public class DepthLookupStrategy extends AbstractLookupStrategy
+public class DepthLookupStrategy extends HierarchyLookupStrategy
 {
-   private boolean checkCurrent;
-
    public DepthLookupStrategy()
    {
       this(true);
@@ -43,12 +41,12 @@
 
    protected DepthLookupStrategy(boolean checkCurrent)
    {
-      this.checkCurrent = checkCurrent;
+      super(checkCurrent);
    }
 
    protected ControllerContext getContextInternal(AbstractController controller, Object name, ControllerState state)
    {
-      return getContextInternal(controller, name, state, checkCurrent);
+      return getContextInternal(controller, name, state, isCheckCurrent());
    }
 
    /**
@@ -65,7 +63,7 @@
       ControllerContext context;
       if (check)
       {
-         context = controller.getContext(name, state);
+         context = getLocalContext(controller, name, state);
          if (context != null)
             return context;
       }
@@ -74,7 +72,7 @@
       for (AbstractController child : children)
       {
          // check child first
-         context = child.getContext(name, state);
+         context = getLocalContext(child, name, state);
          if (context != null)
             return context;
 

Copied: projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/graph/HierarchyLookupStrategy.java (from rev 75493, projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/graph/AbstractLookupStrategy.java)
===================================================================
--- projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/graph/HierarchyLookupStrategy.java	                        (rev 0)
+++ projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/graph/HierarchyLookupStrategy.java	2008-07-09 09:40:20 UTC (rev 75535)
@@ -0,0 +1,52 @@
+/*
+* 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.dependency.plugins.graph;
+
+/**
+ * Hierarchy lookup strategy.
+ * Does local lookup on controller - if supported.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class HierarchyLookupStrategy extends LocalLookupStrategy
+{
+   private boolean checkCurrent;
+
+   protected HierarchyLookupStrategy()
+   {
+   }
+
+   protected HierarchyLookupStrategy(boolean checkCurrent)
+   {
+      this.checkCurrent = checkCurrent;
+   }
+
+   /**
+    * Should we check current / top.
+    *
+    * @return true if check surrent / top
+    */
+   protected boolean isCheckCurrent()
+   {
+      return checkCurrent;
+   }
+}
\ No newline at end of file

Modified: projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/graph/LeavesFirstLookupStrategy.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/graph/LeavesFirstLookupStrategy.java	2008-07-09 09:15:57 UTC (rev 75534)
+++ projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/graph/LeavesFirstLookupStrategy.java	2008-07-09 09:40:20 UTC (rev 75535)
@@ -32,10 +32,8 @@
  *
  * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
  */
-public class LeavesFirstLookupStrategy extends AbstractLookupStrategy
+public class LeavesFirstLookupStrategy extends HierarchyLookupStrategy
 {
-   private boolean checkCurrent;
-
    public LeavesFirstLookupStrategy()
    {
       this(true);
@@ -43,12 +41,12 @@
 
    protected LeavesFirstLookupStrategy(boolean checkCurrent)
    {
-      this.checkCurrent = checkCurrent;
+      super(checkCurrent);
    }
 
    protected ControllerContext getContextInternal(AbstractController controller, Object name, ControllerState state)
    {
-      return getContextInternal(controller, name, state, checkCurrent);
+      return getContextInternal(controller, name, state, isCheckCurrent());
    }
 
    /**
@@ -71,7 +69,7 @@
       }
 
       if (check)
-         return controller.getContext(name, state);
+         return getLocalContext(controller, name, state);
 
       return null;
    }

Modified: projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/graph/LocalLookupStrategy.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/graph/LocalLookupStrategy.java	2008-07-09 09:15:57 UTC (rev 75534)
+++ projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/graph/LocalLookupStrategy.java	2008-07-09 09:40:20 UTC (rev 75535)
@@ -35,6 +35,19 @@
 {
    protected ControllerContext getContextInternal(AbstractController controller, Object name, ControllerState state)
    {
+      return getLocalContext(controller, name, state);
+   }
+
+   /**
+    * Get local context.
+    *
+    * @param controller the controller
+    * @param name the context name
+    * @param state the dependent state
+    * @return found controller context or null
+    */
+   protected ControllerContext getLocalContext(AbstractController controller, Object name, ControllerState state)
+   {
       if (controller instanceof ScopedController)
       {
          ScopedController scopedController = (ScopedController)controller;

Modified: projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/graph/WidthLookupStrategy.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/graph/WidthLookupStrategy.java	2008-07-09 09:15:57 UTC (rev 75534)
+++ projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/graph/WidthLookupStrategy.java	2008-07-09 09:40:20 UTC (rev 75535)
@@ -32,10 +32,8 @@
  *
  * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
  */
-public class WidthLookupStrategy extends AbstractLookupStrategy
+public class WidthLookupStrategy extends HierarchyLookupStrategy
 {
-   private boolean checkCurrent;
-
    public WidthLookupStrategy()
    {
       this(true);
@@ -43,12 +41,12 @@
 
    protected WidthLookupStrategy(boolean checkCurrent)
    {
-      this.checkCurrent = checkCurrent;
+      super(checkCurrent);
    }
 
    protected ControllerContext getContextInternal(AbstractController controller, Object name, ControllerState state)
    {
-      return getContextInternal(controller, name, state, checkCurrent);
+      return getContextInternal(controller, name, state, isCheckCurrent());
    }
 
    /**
@@ -65,7 +63,7 @@
       ControllerContext context;
       if (check)
       {
-         context = controller.getContext(name, state);
+         context = getLocalContext(controller, name, state);
          if (context != null)
             return context;
       }
@@ -73,7 +71,7 @@
       Set<AbstractController> children = controller.getControllers();
       for (AbstractController child : children)
       {
-         context = child.getContext(name, state);
+         context = getLocalContext(child, name, state);
          if (context != null)
             return context;
       }

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractDependencyValueMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractDependencyValueMetaData.java	2008-07-09 09:15:57 UTC (rev 75534)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractDependencyValueMetaData.java	2008-07-09 09:40:20 UTC (rev 75535)
@@ -196,7 +196,7 @@
          return null;
 
       Object result;
-      if (property != null)
+      if (property != null && property.length() > 0)
       {
          if (lookup instanceof AttributeDispatchContext)
          {

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/SearchPropertyAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/SearchPropertyAnnotationPlugin.java	2008-07-09 09:15:57 UTC (rev 75534)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/SearchPropertyAnnotationPlugin.java	2008-07-09 09:40:20 UTC (rev 75535)
@@ -60,12 +60,19 @@
       org.jboss.dependency.plugins.graph.Search type = types.get(searchType.toUpperCase());
       if (type == null)
          throw new IllegalArgumentException("No such search type: " + searchType + ", available: " + Arrays.toString(org.jboss.dependency.plugins.graph.Search.values()));
-      
+
+      ControllerState state = null;
+      if (isAttributePresent(search.dependentState()))
+         state = new ControllerState(search.dependentState());
+      String property= null;
+      if (isAttributePresent(search.property()))
+         property = search.property();
+
       return new SearchValueMetaData(
             search.bean(),
-            new ControllerState(search.dependentState()),
+            state,
             type,
-            search.property()
+            property
       );
    }
 }
\ No newline at end of file

Copied: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/search/AbstractSearchAnnotationSupportTest.java (from rev 75493, projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/search/BasicSearchAnnotationSupportTestCase.java)
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/search/AbstractSearchAnnotationSupportTest.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/search/AbstractSearchAnnotationSupportTest.java	2008-07-09 09:40:20 UTC (rev 75535)
@@ -0,0 +1,89 @@
+/*
+* 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.annotations.test.search;
+
+import java.util.UUID;
+
+import org.jboss.beans.metadata.api.annotations.Aliases;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.kernel.plugins.annotations.AbstractBeanAnnotationAdapter;
+import org.jboss.kernel.plugins.annotations.BasicBeanAnnotationAdapter;
+import org.jboss.kernel.plugins.annotations.BeanAnnotationAdapter;
+import org.jboss.kernel.plugins.annotations.SearchPropertyAnnotationPlugin;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.metadata.plugins.scope.ApplicationScope;
+import org.jboss.metadata.plugins.scope.DeploymentScope;
+import org.jboss.metadata.plugins.scope.InstanceScope;
+import org.jboss.test.kernel.annotations.support.ScopeTester;
+import org.jboss.test.kernel.annotations.test.AbstractBeanAnnotationAdapterTest;
+
+/**
+ * Abstract search annotation IoC support
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class AbstractSearchAnnotationSupportTest extends AbstractBeanAnnotationAdapterTest
+{
+   protected AbstractSearchAnnotationSupportTest(String name)
+   {
+      super(name);
+   }
+
+   protected BeanAnnotationAdapter getBeanAnnotationAdapterClass()
+   {
+      AbstractBeanAnnotationAdapter adapter = BasicBeanAnnotationAdapter.INSTANCE;
+      adapter.addAnnotationPlugin(SearchPropertyAnnotationPlugin.INSTANCE);
+      return adapter;
+   }
+
+   protected void tearDown() throws Exception
+   {
+      AbstractBeanAnnotationAdapter adapter = BasicBeanAnnotationAdapter.INSTANCE;
+      adapter.removeAnnotationPlugin(SearchPropertyAnnotationPlugin.INSTANCE);
+
+      super.tearDown();
+   }
+
+   protected void assertScopeTester(ScopeTester tester, String scope)
+   {
+      assertNotNull(scope, tester);
+      assertEquals(scope, tester.getScope());
+   }
+
+   protected ControllerContext install(String scope, String app, String deployment, int id) throws Throwable
+   {
+      BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(UUID.randomUUID().toString(), ScopeTester.class.getName());
+      builder.addConstructorParameter(String.class.getName(), scope);
+      builder.addAnnotation("@" + Aliases.class.getName() + "({\"bean\"})");
+
+      if (app != null)
+         builder.addAnnotation("@" + ApplicationScope.class.getName() + "(\"" + app + "\")");
+      if (deployment != null)
+         builder.addAnnotation("@" + DeploymentScope.class.getName() + "(\"" + deployment + "\")");
+      if (id > 0)
+         builder.addAnnotation("@" + InstanceScope.class.getName() + "(\"id-" + Integer.toString(id) + "\")");
+
+      KernelController controller = getController();
+      return controller.install(builder.getBeanMetaData());
+   }
+}
\ No newline at end of file

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/search/BasicSearchAnnotationSupportTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/search/BasicSearchAnnotationSupportTestCase.java	2008-07-09 09:15:57 UTC (rev 75534)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/search/BasicSearchAnnotationSupportTestCase.java	2008-07-09 09:40:20 UTC (rev 75535)
@@ -24,30 +24,17 @@
 import java.util.ArrayList;
 import java.util.List;
 import java.util.ListIterator;
-import java.util.UUID;
 
 import junit.framework.Test;
-import org.jboss.beans.metadata.api.annotations.Aliases;
-import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
 import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.kernel.plugins.annotations.AbstractBeanAnnotationAdapter;
-import org.jboss.kernel.plugins.annotations.BasicBeanAnnotationAdapter;
-import org.jboss.kernel.plugins.annotations.BeanAnnotationAdapter;
-import org.jboss.kernel.plugins.annotations.SearchPropertyAnnotationPlugin;
-import org.jboss.kernel.spi.dependency.KernelController;
-import org.jboss.metadata.plugins.scope.ApplicationScope;
-import org.jboss.metadata.plugins.scope.DeploymentScope;
-import org.jboss.metadata.plugins.scope.InstanceScope;
-import org.jboss.test.kernel.annotations.support.ScopeTester;
 import org.jboss.test.kernel.annotations.support.SearchInjection;
-import org.jboss.test.kernel.annotations.test.AbstractBeanAnnotationAdapterTest;
 
 /**
  * Basic search annotation IoC support
  *
  * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
  */
-public class BasicSearchAnnotationSupportTestCase extends AbstractBeanAnnotationAdapterTest
+public class BasicSearchAnnotationSupportTestCase extends AbstractSearchAnnotationSupportTest
 {
    public BasicSearchAnnotationSupportTestCase(String name)
    {
@@ -59,13 +46,6 @@
       return suite(BasicSearchAnnotationSupportTestCase.class);
    }
 
-   protected BeanAnnotationAdapter getBeanAnnotationAdapterClass()
-   {
-      AbstractBeanAnnotationAdapter adapter = BasicBeanAnnotationAdapter.INSTANCE;
-      adapter.addAnnotationPlugin(SearchPropertyAnnotationPlugin.INSTANCE);
-      return adapter;
-   }
-
    public void testSearchTypes() throws Throwable
    {
       List<ControllerContext> contexts = new ArrayList<ControllerContext>();
@@ -99,27 +79,4 @@
       assertScopeTester(si.getChildrenOnly(), "child");
       assertScopeTester(si.getLeaves(), "child");      
    }
-
-   protected void assertScopeTester(ScopeTester tester, String scope)
-   {
-      assertNotNull(scope, tester);
-      assertEquals(scope, tester.getScope());
-   }
-
-   protected ControllerContext install(String scope, String app, String deployment, int id) throws Throwable
-   {
-      BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(UUID.randomUUID().toString(), ScopeTester.class.getName());
-      builder.addConstructorParameter(String.class.getName(), scope);
-      builder.addAnnotation("@" + Aliases.class.getName() + "({\"bean\"})");
-
-      if (app != null)
-         builder.addAnnotation("@" + ApplicationScope.class.getName() + "(\"" + app + "\")");
-      if (deployment != null)
-         builder.addAnnotation("@" + DeploymentScope.class.getName() + "(\"" + deployment + "\")");
-      if (id > 0)
-         builder.addAnnotation("@" + InstanceScope.class.getName() + "(\"id-" + Integer.toString(id) + "\")");
-
-      KernelController controller = getController();
-      return controller.install(builder.getBeanMetaData());
-   }
 }
\ No newline at end of file

Copied: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/search/OrderSearchAnnotationSupportTestCase.java (from rev 75493, projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/search/BasicSearchAnnotationSupportTestCase.java)
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/search/OrderSearchAnnotationSupportTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/search/OrderSearchAnnotationSupportTestCase.java	2008-07-09 09:40:20 UTC (rev 75535)
@@ -0,0 +1,102 @@
+/*
+* 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.annotations.test.search;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ListIterator;
+
+import junit.framework.Test;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.plugins.annotations.AbstractBeanAnnotationAdapter;
+import org.jboss.kernel.plugins.annotations.BasicBeanAnnotationAdapter;
+import org.jboss.kernel.plugins.annotations.SearchPropertyAnnotationPlugin;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.test.kernel.annotations.support.SearchInjection;
+
+/**
+ * Order search annotation IoC support
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class OrderSearchAnnotationSupportTestCase extends AbstractSearchAnnotationSupportTest
+{
+   public OrderSearchAnnotationSupportTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(OrderSearchAnnotationSupportTestCase.class);
+   }
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+
+      AbstractBeanAnnotationAdapter adapter = BasicBeanAnnotationAdapter.INSTANCE;
+      adapter.addAnnotationPlugin(SearchPropertyAnnotationPlugin.INSTANCE);
+   }
+
+   public void testWrongOrder() throws Throwable
+   {
+      KernelController controller = getController();
+      ControllerContext context = controller.install(new AbstractBeanMetaData("si", SearchInjection.class.getName()));
+      assertEquals(ControllerState.INSTANTIATED, context.getState());
+
+      List<ControllerContext> contexts = new ArrayList<ControllerContext>();
+      try
+      {
+         contexts.add(install("top", null, null, -1));
+         contexts.add(install("local", "main", "core", -1));
+
+         contexts.add(install("child", "main", "core", 1));
+         // here we need a little push - since by default we only do parent hierarchy resolution
+         controller.change(context, ControllerState.INSTALLED);
+
+         assertEquals(ControllerState.INSTALLED, context.getState());
+         doTestAfterInstall(context.getTarget());
+      }
+      finally
+      {
+         ListIterator<ControllerContext> iter = contexts.listIterator(contexts.size());
+         while (iter.hasPrevious())
+         {
+            getController().uninstall(iter.previous().getName());
+         }
+      }
+   }
+
+   protected void doTestAfterInstall(Object target)
+   {
+      SearchInjection si = (SearchInjection)target;
+      // ony check exact one's
+      assertScopeTester(si.getTop(), "top");
+      assertScopeTester(si.getParent(), "top");
+      assertScopeTester(si.getLocal(), "local");
+      assertScopeTester(si.getChildrenOnly(), "child");
+      assertScopeTester(si.getLeaves(), "child");
+   }
+}
\ No newline at end of file

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/search/SearchTestSuite.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/search/SearchTestSuite.java	2008-07-09 09:15:57 UTC (rev 75534)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/search/SearchTestSuite.java	2008-07-09 09:40:20 UTC (rev 75535)
@@ -42,6 +42,7 @@
       TestSuite suite = new TestSuite("Search Tests");
 
       suite.addTest(BasicSearchAnnotationSupportTestCase.suite());
+      suite.addTest(OrderSearchAnnotationSupportTestCase.suite());
 
       return suite;
    }




More information about the jboss-cvs-commits mailing list