@@ -0,0 +1,1607 @@
+package org.jboss.weld.test;%0A%0Aimport org.jboss.testharness.impl.runner.servlet.ServletTestRunner;%0Aimport org.jboss.weld.BeanManagerImpl;%0Aimport org.jboss.weld.Container;%0Aimport org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;%0Aimport org.jboss.weld.servlet.ServletHelper;%0A%0Apublic class BeanManagerLocator%0A%7B%0A   %0A   public static BeanManagerLocator INSTANCE = new BeanManagerLocator();%0A   %0A   private BeanManagerLocator()%0A   %7B%0A      // TODO Auto-generated constructor stub%0A   %7D%0A   %0A   private BeanDeploymentArchive testArchive;%0A   %0A   public BeanManagerImpl locate()%0A   %7B%0A      if (ServletTestRunner.getCurrentServletContext() != null)%0A      %7B%0A         return ServletHelper.getModuleBeanManager(ServletTestRunner.getCurrentServletContext());%0A      %7D%0A      else if (getTestArchive() != null)%0A      %7B%0A         return Container.instance().beanDeploymentArchives().get(getTestArchive());%0A      %7D%0A      else%0A      %7B%0A         throw new IllegalStateException();%0A      %7D%0A   %7D%0A   %0A   private BeanDeploymentArchive getTestArchive()%0A   %7B%0A      if (testArchive == null)%0A      %7B%0A         try%0A         %7B%0A            testArchive = (BeanDeploymentArchive) Class.forName(%22org.jboss.weld.mock.MockBeanDeploymentArchive%22).newInstance();%0A         %7D%0A         catch (InstantiationException e)%0A         %7B%0A            throw new IllegalStateException(e);%0A         %7D%0A         catch (IllegalAccessException e)%0A         %7B%0A            throw new IllegalStateException(e);%0A         %7D%0A         catch (ClassNotFoundException e)%0A         %7B%0A            throw new IllegalStateException(e);%0A         %7D%0A      %7D%0A      return testArchive;%0A   %7D%0A%0A%7D%0A

Split out how we locate the bean manager for the test