[weld-commits] Weld SVN: r3882 - in ri/trunk/tests/src/main/java/org/jboss: weld and 5 other directories.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Wed Oct 7 23:57:13 EDT 2009


Author: shane.bryzak at jboss.com
Date: 2009-10-07 23:57:13 -0400 (Wed, 07 Oct 2009)
New Revision: 3882

Added:
   ri/trunk/tests/src/main/java/org/jboss/weld/
   ri/trunk/tests/src/main/java/org/jboss/weld/mock/
   ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockBeanDeploymentArchive.java
   ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockDeployment.java
   ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockEELifecycle.java
   ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockEjBServices.java
   ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockEjbDescriptor.java
   ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockEjbInjectionServices.java
   ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockHttpSession.java
   ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockJpaServices.java
   ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockLifecycle.java
   ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockResourceLoader.java
   ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockResourceServices.java
   ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockSecurityServices.java
   ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockServletContext.java
   ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockServletLifecycle.java
   ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockServletServices.java
   ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockTransactionServices.java
   ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockValidationServices.java
   ri/trunk/tests/src/main/java/org/jboss/weld/mock/TestContainer.java
   ri/trunk/tests/src/main/java/org/jboss/weld/mock/cluster/
   ri/trunk/tests/src/main/java/org/jboss/weld/mock/el/
   ri/trunk/tests/src/main/java/org/jboss/weld/test/
   ri/trunk/tests/src/main/java/org/jboss/weld/test/AbstractWebBeansTest.java
   ri/trunk/tests/src/main/java/org/jboss/weld/test/harness/
Removed:
   ri/trunk/tests/src/main/java/org/jboss/webbeans/
Modified:
   ri/trunk/tests/src/main/java/org/jboss/weld/mock/cluster/AbstractClusterTest.java
   ri/trunk/tests/src/main/java/org/jboss/weld/mock/cluster/SwitchableMockEELifecycle.java
   ri/trunk/tests/src/main/java/org/jboss/weld/mock/cluster/SwitchableSingletonProvider.java
   ri/trunk/tests/src/main/java/org/jboss/weld/mock/el/EL.java
   ri/trunk/tests/src/main/java/org/jboss/weld/test/harness/AbstractStandaloneContainersImpl.java
   ri/trunk/tests/src/main/java/org/jboss/weld/test/harness/ServletLifecycleContainersImpl.java
   ri/trunk/tests/src/main/java/org/jboss/weld/test/harness/StandaloneContainersImpl.java
Log:
refactored core tests packages


Copied: ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockBeanDeploymentArchive.java (from rev 3872, ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockBeanDeploymentArchive.java)
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockBeanDeploymentArchive.java	                        (rev 0)
+++ ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockBeanDeploymentArchive.java	2009-10-08 03:57:13 UTC (rev 3882)
@@ -0,0 +1,115 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.mock;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.ejb.MessageDriven;
+import javax.ejb.Singleton;
+import javax.ejb.Stateful;
+import javax.ejb.Stateless;
+
+import org.jboss.weld.bootstrap.api.ServiceRegistry;
+import org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry;
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.weld.ejb.spi.EjbDescriptor;
+
+/**
+ * @author pmuir
+ *
+ */
+public class MockBeanDeploymentArchive implements BeanDeploymentArchive
+{
+   
+
+   private Collection<Class<?>> beanClasses;
+   private Collection<URL> beansXmlFiles;
+   private List<EjbDescriptor<?>> ejbs;
+   private final ServiceRegistry services;
+   
+   public MockBeanDeploymentArchive()
+   {
+      this.services = new SimpleServiceRegistry();
+      this.beanClasses = new HashSet<Class<?>>();
+      this.beansXmlFiles = new HashSet<URL>();
+   }
+
+   public Collection<Class<?>> getBeanClasses()
+   {
+      return beanClasses;
+   }
+   
+   public void setBeanClasses(Collection<Class<?>> beanClasses)
+   {
+      this.beanClasses = beanClasses;
+      ejbs = new ArrayList<EjbDescriptor<?>>();
+      for (Class<?> ejbClass : discoverEjbs(getBeanClasses()))
+      {
+         ejbs.add(MockEjbDescriptor.of(ejbClass));
+      }
+   }
+
+   public Collection<URL> getBeansXml()
+   {
+      return beansXmlFiles;
+   }
+   
+   public void setBeansXmlFiles(Collection<URL> beansXmlFiles)
+   {
+      this.beansXmlFiles = beansXmlFiles;
+   }
+
+   public List<BeanDeploymentArchive> getBeanDeploymentArchives()
+   {
+      return Collections.emptyList();
+   }
+   
+   public Collection<EjbDescriptor<?>> getEjbs()
+   {
+      return ejbs;
+   }
+   
+   protected static Iterable<Class<?>> discoverEjbs(Iterable<Class<?>> webBeanClasses)
+   {
+      Set<Class<?>> ejbs = new HashSet<Class<?>>();
+      for (Class<?> clazz : webBeanClasses)
+      {
+         if (clazz.isAnnotationPresent(Stateless.class) || clazz.isAnnotationPresent(Stateful.class) || clazz.isAnnotationPresent(MessageDriven.class) || clazz.isAnnotationPresent(Singleton.class)) 
+         {
+            ejbs.add(clazz);
+         }
+      }
+      return ejbs;
+   }
+   
+   public ServiceRegistry getServices()
+   {
+      return services;
+   }
+   
+   public String getId()
+   {
+      return "test";
+   }
+
+}

Copied: ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockDeployment.java (from rev 3872, ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockDeployment.java)
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockDeployment.java	                        (rev 0)
+++ ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockDeployment.java	2009-10-08 03:57:13 UTC (rev 3882)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.mock;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.weld.bootstrap.api.ServiceRegistry;
+import org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry;
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.weld.bootstrap.spi.Deployment;
+
+public class MockDeployment implements Deployment
+{
+   
+   private final MockBeanDeploymentArchive archive;
+   private final List<BeanDeploymentArchive> beanDeploymentArchives;
+   private final ServiceRegistry services;
+   
+   public MockDeployment()
+   {
+      this.archive = new MockBeanDeploymentArchive();
+      this.services = new SimpleServiceRegistry();
+      this.beanDeploymentArchives = new ArrayList<BeanDeploymentArchive>();
+      this.beanDeploymentArchives.add(archive);
+   }
+   
+   public List<BeanDeploymentArchive> getBeanDeploymentArchives()
+   {
+      return beanDeploymentArchives;
+   }
+
+   public BeanDeploymentArchive loadBeanDeploymentArchive(Class<?> beanClass)
+   {
+      return archive;
+   }
+   
+   public MockBeanDeploymentArchive getArchive()
+   {
+      return archive;
+   }
+
+   public ServiceRegistry getServices()
+   {
+      return services;
+   }
+
+}

Copied: ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockEELifecycle.java (from rev 3872, ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEELifecycle.java)
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockEELifecycle.java	                        (rev 0)
+++ ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockEELifecycle.java	2009-10-08 03:57:13 UTC (rev 3882)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.mock;
+
+import org.jboss.weld.bootstrap.api.Environment;
+import org.jboss.weld.bootstrap.api.Environments;
+import org.jboss.weld.ejb.spi.EjbServices;
+import org.jboss.weld.injection.spi.EjbInjectionServices;
+import org.jboss.weld.injection.spi.JpaInjectionServices;
+import org.jboss.weld.injection.spi.ResourceInjectionServices;
+import org.jboss.weld.security.spi.SecurityServices;
+import org.jboss.weld.transaction.spi.TransactionServices;
+import org.jboss.weld.validation.spi.ValidationServices;
+
+public class MockEELifecycle extends MockServletLifecycle
+{
+   
+   private static final TransactionServices MOCK_TRANSACTION_SERVICES = new MockTransactionServices();
+
+   public MockEELifecycle()
+   {
+      super();
+      getDeployment().getServices().add(TransactionServices.class, MOCK_TRANSACTION_SERVICES);
+      getDeployment().getServices().add(SecurityServices.class, new MockSecurityServices());
+      getDeployment().getServices().add(ValidationServices.class, new MockValidationServices());
+      getDeployment().getServices().add(EjbServices.class, new MockEjBServices());
+      getDeployment().getArchive().getServices().add(EjbInjectionServices.class, new MockEjbInjectionServices());
+      getDeployment().getArchive().getServices().add(JpaInjectionServices.class, new MockJpaServices(getDeployment()));
+      getDeployment().getArchive().getServices().add(ResourceInjectionServices.class, new MockResourceServices());
+   }
+   
+   public Environment getEnvironment()
+   {
+      return Environments.EE_INJECT;
+   }
+   
+}

Copied: ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockEjBServices.java (from rev 3872, ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java)
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockEjBServices.java	                        (rev 0)
+++ ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockEjBServices.java	2009-10-08 03:57:13 UTC (rev 3882)
@@ -0,0 +1,51 @@
+/**
+ *
+ */
+package org.jboss.weld.mock;
+
+import org.jboss.weld.ejb.api.SessionObjectReference;
+import org.jboss.weld.ejb.spi.EjbDescriptor;
+import org.jboss.weld.ejb.spi.EjbServices;
+import org.jboss.weld.ejb.spi.InterceptorBindings;
+
+public class MockEjBServices implements EjbServices
+{
+
+
+
+   public SessionObjectReference resolveEjb(EjbDescriptor<?> ejbDescriptor)
+   {
+      return new SessionObjectReference()
+      {
+
+         private static final long serialVersionUID = 1L;
+
+         public <S> S getBusinessObject(Class<S> businessInterfaceType)
+         {
+            // TODO Auto-generated method stub
+            return null;
+         }
+
+         public void remove()
+         {
+            // TODO Auto-generated method stub
+
+         }
+
+         public boolean isRemoved()
+         {
+            // TODO Auto-generated method stub
+            return false;
+         }
+
+      };
+   }
+
+   public void registerInterceptors(EjbDescriptor<?> ejbDescriptor, InterceptorBindings interceptorBindings)
+   {
+      // do nothing
+   }
+
+   public void cleanup() {}
+
+}

Copied: ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockEjbDescriptor.java (from rev 3872, ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEjbDescriptor.java)
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockEjbDescriptor.java	                        (rev 0)
+++ ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockEjbDescriptor.java	2009-10-08 03:57:13 UTC (rev 3882)
@@ -0,0 +1,201 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.mock;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+
+import javax.ejb.Local;
+import javax.ejb.MessageDriven;
+import javax.ejb.Remove;
+import javax.ejb.Singleton;
+import javax.ejb.Stateful;
+import javax.ejb.Stateless;
+
+import org.jboss.weld.ejb.spi.BusinessInterfaceDescriptor;
+import org.jboss.weld.ejb.spi.EjbDescriptor;
+
+public class MockEjbDescriptor<T> implements EjbDescriptor<T>
+{
+   private final Class<T> beanClass;
+   private final String ejbName;
+   private final List<BusinessInterfaceDescriptor<?>> localInterfaces;
+   private final HashSet<Method> removeMethods;
+   
+   public static <T> MockEjbDescriptor<T> of(Class<T> type)
+   {
+      return new MockEjbDescriptor<T>(type);
+   }
+
+   private MockEjbDescriptor(final Class<T> type)
+   {
+      this.beanClass = type;
+      this.ejbName = type.getSimpleName();
+      this.localInterfaces = new ArrayList<BusinessInterfaceDescriptor<?>>();
+      
+      Local localAnnotation = type.getAnnotation(Local.class);
+      if (localAnnotation != null)
+      {
+         for (final Class<?> clazz : localAnnotation.value())
+         {
+            localInterfaces.add(createBusinessInterfaceDescriptor(clazz));
+         }
+      }
+      
+      for (final Class<?> clazz : type.getInterfaces())
+      {
+         if (clazz.isAnnotationPresent(Local.class))
+         {
+            localInterfaces.add(createBusinessInterfaceDescriptor(clazz));
+         }
+      }
+      // cope with EJB 3.1 style no-interface views
+      if (localInterfaces.size() == 0)
+      {
+         localInterfaces.add(createBusinessInterfaceDescriptor(type));
+      }
+      this.removeMethods = new HashSet<Method>();
+      for (final Method method : type.getMethods())
+      {
+         if (method.isAnnotationPresent(Remove.class))
+         {
+            removeMethods.add(method);
+         }
+      }
+   }
+
+   private BusinessInterfaceDescriptor<Object> createBusinessInterfaceDescriptor(final Class<?> clazz)
+   {
+      return new BusinessInterfaceDescriptor<Object>()
+      {
+  
+         @SuppressWarnings("unchecked")
+         public Class<Object> getInterface()
+         {
+            return (Class<Object>) clazz;
+         }
+  
+         public String getJndiName()
+         {
+            return clazz.getSimpleName() + "/local";
+         }
+      
+      };
+   }
+
+   public String getEjbName()
+   {
+      return ejbName;
+   }
+
+   public Collection<BusinessInterfaceDescriptor<?>> getLocalBusinessInterfaces()
+   {
+      return localInterfaces;
+   }
+   
+   public Iterable<BusinessInterfaceDescriptor<?>> getRemoteBusinessInterfaces()
+   {
+      return Collections.emptyList();
+   }
+
+   public Collection<Method> getRemoveMethods()
+   {
+
+      return removeMethods;
+   }
+
+   public Class<T> getBeanClass()
+   {
+      return beanClass;
+   }
+
+   public boolean isMessageDriven()
+   {
+      return beanClass.isAnnotationPresent(MessageDriven.class);
+   }
+
+   public boolean isSingleton()
+   {
+      return beanClass.isAnnotationPresent(Singleton.class);
+   }
+
+   public boolean isStateful()
+   {
+      return beanClass.isAnnotationPresent(Stateful.class);
+   }
+
+   public boolean isStateless()
+   {
+      return beanClass.isAnnotationPresent(Stateless.class);
+   }
+   
+   public String getLocalJndiName()
+   {
+      return beanClass.getSimpleName() + "/local";
+   }
+   
+   @Override
+   public String toString()
+   {
+      StringBuilder builder = new StringBuilder();
+      builder.append(getEjbName());
+      if (isStateful())
+      {
+         builder.append(" (SFSB)");
+      }
+      if (isStateless())
+      {
+         builder.append(" (SLSB)");
+      }
+      if (isSingleton())
+      {
+         builder.append(" (Singleton)");
+      }
+      if (isMessageDriven())
+      {
+         builder.append(" (MDB)");
+      }
+      builder.append("remove methods; " + removeMethods + "; ");
+      builder.append("; BeanClass: " + getBeanClass() + "; Local Business Interfaces: " + getLocalBusinessInterfaces());
+      return builder.toString(); 
+   }
+   
+//   @Override
+//   public boolean equals(Object other)
+//   {
+//      if (other instanceof EjbDescriptor)
+//      {
+//         EjbDescriptor<T> that = (EjbDescriptor<T>) other;
+//         return this.getBeanClass().equals(that.getBeanClass());
+//      }
+//      else
+//      {
+//         return false;
+//      }
+//   }
+//   
+//   @Override
+//   public int hashCode()
+//   {
+//      return getEjbName().hashCode();
+//   }
+
+}

Copied: ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockEjbInjectionServices.java (from rev 3872, ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEjbInjectionServices.java)
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockEjbInjectionServices.java	                        (rev 0)
+++ ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockEjbInjectionServices.java	2009-10-08 03:57:13 UTC (rev 3882)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.mock;
+
+import javax.enterprise.inject.spi.InjectionPoint;
+
+import org.jboss.weld.injection.spi.EjbInjectionServices;
+
+/**
+ * @author pmuir
+ *
+ */
+public class MockEjbInjectionServices implements EjbInjectionServices
+{
+
+   public Object resolveEjb(InjectionPoint injectionPoint)
+   {
+      return null;
+   }
+   
+   public void cleanup() {}
+
+}

Copied: ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockHttpSession.java (from rev 3872, ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockHttpSession.java)
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockHttpSession.java	                        (rev 0)
+++ ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockHttpSession.java	2009-10-08 03:57:13 UTC (rev 3882)
@@ -0,0 +1,161 @@
+package org.jboss.weld.mock;
+
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpSessionContext;
+
+/**
+ * A mock implementation of the HttpSession interface for tests.
+ * 
+ * @author Dan Allen
+ */
+public class MockHttpSession implements HttpSession
+{
+   private String id;
+   
+   private ServletContext servletContext;
+   
+   private Map<String, Object> attributes = new HashMap<String, Object>();
+
+   private boolean invalid = false;
+   
+   private int maxInactiveInterval = 60;
+   
+   private int lastAccessedTime = -1;
+   
+   public MockHttpSession() {}
+   
+   public MockHttpSession(String id)
+   {
+      this.id = id;
+   }
+   
+   public MockHttpSession(String id, ServletContext servletContext)
+   {
+      this(id);
+      this.servletContext = servletContext;
+   }
+
+   public Object getAttribute(String name)
+   {
+      return attributes.get(name);
+   }
+
+   public Enumeration<String> getAttributeNames()
+   {
+      final Iterator<String> nameIterator = attributes.keySet().iterator();
+      return new Enumeration<String>()
+      {
+
+         public boolean hasMoreElements()
+         {
+            return nameIterator.hasNext();
+         }
+
+         public String nextElement()
+         {
+            return nameIterator.next();
+         }
+      };
+   }
+
+   public long getCreationTime()
+   {
+      return 0;
+   }
+
+   public String getId()
+   {
+      return id;
+   }
+
+   public long getLastAccessedTime()
+   {
+      return lastAccessedTime;
+   }
+
+   public int getMaxInactiveInterval()
+   {
+      return maxInactiveInterval;
+   }
+
+   public ServletContext getServletContext()
+   {
+      return servletContext;
+   }
+
+   @SuppressWarnings("deprecation")
+   public HttpSessionContext getSessionContext()
+   {
+      throw new UnsupportedOperationException();
+   }
+
+   public Object getValue(String name)
+   {
+      return getAttribute(name);
+   }
+
+   public String[] getValueNames()
+   {
+      return attributes.keySet().toArray(new String[0]);
+   }
+
+   public void invalidate()
+   {
+      attributes.clear();
+      invalid = true;
+   }
+
+   public boolean isNew()
+   {
+      return false;
+   }
+
+   public void putValue(String name, Object value)
+   {
+      setAttribute(name, value);
+   }
+
+   public void removeAttribute(String name)
+   {
+      attributes.remove(name);
+   }
+
+   public void removeValue(String name)
+   {
+      removeAttribute(name);
+   }
+
+   public void setAttribute(String name, Object value)
+   {
+      if (value == null)
+      {
+         removeAttribute(name);
+      }
+      else
+      {
+         attributes.put(name, value);
+      }
+   }
+
+   public void setMaxInactiveInterval(int seconds)
+   {
+      maxInactiveInterval = seconds;
+   }
+   
+   public boolean isInvalid()
+   {
+      return invalid;
+   }
+   
+   public void access()
+   {
+      lastAccessedTime = (int) System.currentTimeMillis();
+   }
+
+}

Copied: ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockJpaServices.java (from rev 3872, ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockJpaServices.java)
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockJpaServices.java	                        (rev 0)
+++ ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockJpaServices.java	2009-10-08 03:57:13 UTC (rev 3882)
@@ -0,0 +1,66 @@
+/**
+ * 
+ */
+package org.jboss.weld.mock;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.persistence.Entity;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.weld.bootstrap.spi.Deployment;
+import org.jboss.weld.injection.spi.JpaInjectionServices;
+
+public class MockJpaServices implements JpaInjectionServices
+{
+   
+   private final Deployment deployment;
+   
+   public MockJpaServices(Deployment deployment)
+   {
+      this.deployment = deployment;
+   }
+   
+   public EntityManager resolvePersistenceContext(InjectionPoint injectionPoint)
+   {
+      return null;
+   }
+   
+   public EntityManagerFactory resolvePersistenceUnit(InjectionPoint injectionPoint)
+   {
+      return null;
+   }
+   
+   public Collection<Class<?>> discoverEntities()
+   {
+      Set<Class<?>> classes = new HashSet<Class<?>>();
+      for (BeanDeploymentArchive archive : deployment.getBeanDeploymentArchives())
+      {
+         discoverEntities(archive, classes);
+      }
+      return classes;
+   }
+   
+   private void discoverEntities(BeanDeploymentArchive archive, Set<Class<?>> classes)
+   {
+      for (Class<?> clazz : archive.getBeanClasses())
+      {
+         if (clazz.isAnnotationPresent(Entity.class))
+         {
+            classes.add(clazz);
+         }
+      }
+      for (BeanDeploymentArchive child : archive.getBeanDeploymentArchives())
+      {
+         discoverEntities(child, classes);
+      }
+   }
+   
+   public void cleanup() {}
+
+}
\ No newline at end of file

Copied: ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockLifecycle.java (from rev 3872, ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockLifecycle.java)
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockLifecycle.java	                        (rev 0)
+++ ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockLifecycle.java	2009-10-08 03:57:13 UTC (rev 3882)
@@ -0,0 +1,24 @@
+package org.jboss.weld.mock;
+
+import org.jboss.weld.bootstrap.api.Lifecycle;
+
+public interface MockLifecycle extends Lifecycle
+{
+
+   public abstract void initialize();
+
+   public abstract void beginApplication();
+
+   public abstract void endApplication();
+
+   public abstract void resetContexts();
+
+   public abstract void beginRequest();
+
+   public abstract void endRequest();
+
+   public abstract void beginSession();
+
+   public abstract void endSession();
+
+}
\ No newline at end of file

Copied: ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockResourceLoader.java (from rev 3872, ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockResourceLoader.java)
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockResourceLoader.java	                        (rev 0)
+++ ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockResourceLoader.java	2009-10-08 03:57:13 UTC (rev 3882)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.mock;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Collection;
+
+import org.jboss.weld.resources.spi.ResourceLoader;
+import org.jboss.weld.resources.spi.ResourceLoadingException;
+import org.jboss.weld.util.collections.EnumerationList;
+
+public class MockResourceLoader implements ResourceLoader
+{
+   
+   public Class<?> classForName(String name)
+   {
+      try
+      {
+         return Thread.currentThread().getContextClassLoader().loadClass(name);
+      }
+      catch (ClassNotFoundException e)
+      {
+         throw new ResourceLoadingException(e);
+      }
+   }
+   
+   public URL getResource(String name)
+   {
+      return Thread.currentThread().getContextClassLoader().getResource(name);
+   }
+   
+   public Collection<URL> getResources(String name)
+   {
+      try
+      {
+         return new EnumerationList<URL>(Thread.currentThread().getContextClassLoader().getResources(name));
+      }
+      catch (IOException e)
+      {
+         throw new ResourceLoadingException(e);
+      }
+   }
+   
+   public void cleanup() {}
+   
+}

Copied: ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockResourceServices.java (from rev 3872, ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockResourceServices.java)
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockResourceServices.java	                        (rev 0)
+++ ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockResourceServices.java	2009-10-08 03:57:13 UTC (rev 3882)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.mock;
+
+import javax.enterprise.inject.spi.InjectionPoint;
+
+import org.jboss.weld.injection.spi.ResourceInjectionServices;
+
+/**
+ * @author Pete Muir
+ *
+ */
+public class MockResourceServices implements ResourceInjectionServices
+{
+
+   public Object resolveResource(InjectionPoint injectionPoint)
+   {
+      return null;
+   }
+   
+   public Object resolveResource(String jndiName, String mappedName)
+   {
+      return null;
+   }
+   
+   public void cleanup() {}
+   
+}

Copied: ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockSecurityServices.java (from rev 3872, ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockSecurityServices.java)
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockSecurityServices.java	                        (rev 0)
+++ ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockSecurityServices.java	2009-10-08 03:57:13 UTC (rev 3882)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.mock;
+
+import java.security.Principal;
+
+import org.jboss.weld.security.spi.SecurityServices;
+
+/**
+ * @author pmuir
+ *
+ */
+public class MockSecurityServices implements SecurityServices
+{
+
+   /* (non-Javadoc)
+    * @see org.jboss.webbeans.security.spi.SecurityServices#getPrincipal()
+    */
+   public Principal getPrincipal()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+   
+   public void cleanup() {}
+
+}

Copied: ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockServletContext.java (from rev 3872, ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockServletContext.java)
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockServletContext.java	                        (rev 0)
+++ ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockServletContext.java	2009-10-08 03:57:13 UTC (rev 3882)
@@ -0,0 +1,558 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.mock;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+/**
+ * Mock implementation of the servlet context for testing purposes. This implementation supports all
+ * of the standard context methods except that request dispatching just indicates what is being
+ * dispatched to, rather than doing the actual dispatch.
+ * <p>
+ * The context can be configured with a path parameter that should point to an absolute directory
+ * location that represents the place where the contents of the WAR bundle are located. Setting this
+ * value allows all of the resource location functionality to work as in a fully functioning web
+ * application. This value is not set then not resource location functionality will work and instead
+ * null will always be returned.
+ *
+ * Adapted from Apache Wicket
+ * 
+ * @author Chris Turner (Wicket)
+ */
+public class MockServletContext implements ServletContext
+{
+	private final Map<String, Object> attributes = new HashMap<String, Object>();
+
+	private final Map<String, String> initParameters = new HashMap<String, String>();
+
+	/** Map of mime types */
+	private final Map<String, String> mimeTypes = new HashMap<String, String>();
+
+	private File webappRoot;
+
+	/**
+	 * Create the mock object. As part of the creation, the context sets the root directory where
+	 * web application content is stored. This must be an ABSOLUTE directory relative to where the
+	 * tests are being executed. For example: <code>System.getProperty("user.dir") +
+	 * "/src/webapp"</code>
+	 * 
+	 * @param application
+	 *            The application that this context is for
+	 * @param path
+	 *            The path to the root of the web application
+	 */
+	public MockServletContext(final String path)
+	{
+		webappRoot = null;
+		if (path != null)
+		{
+			webappRoot = new File(path);
+			if (!webappRoot.exists() || !webappRoot.isDirectory())
+			{
+				//log.warn("WARNING: The webapp root directory is invalid: " + path);
+				webappRoot = null;
+			}
+		}
+
+		// assume we're running in maven or an eclipse project created by maven,
+		// so the sessions directory will be created inside the target directory,
+		// and will be cleaned up with a mvn clean
+
+		File file = new File("target/work/");
+		file.mkdirs();
+		attributes.put("javax.servlet.context.tempdir", file);
+
+		mimeTypes.put("html", "text/html");
+		mimeTypes.put("htm", "text/html");
+		mimeTypes.put("css", "text/css");
+		mimeTypes.put("xml", "text/xml");
+		mimeTypes.put("js", "text/plain");
+		mimeTypes.put("gif", "image/gif");
+		mimeTypes.put("jpg", "image/jpeg");
+		mimeTypes.put("png", "image/png");
+	}
+
+	/**
+	 * Add an init parameter.
+	 * 
+	 * @param name
+	 *            The parameter name
+	 * @param value
+	 *            The parameter value
+	 */
+	public void addInitParameter(final String name, final String value)
+	{
+		initParameters.put(name, value);
+	}
+
+	// Configuration methods
+
+	/**
+	 * Add a new recognized mime type.
+	 * 
+	 * @param fileExtension
+	 *            The file extension (e.g. "jpg")
+	 * @param mimeType
+	 *            The mime type (e.g. "image/jpeg")
+	 */
+	public void addMimeType(final String fileExtension, final String mimeType)
+	{
+		mimeTypes.put(fileExtension, mimeType);
+	}
+
+	/**
+	 * Get an attribute with the given name.
+	 * 
+	 * @param name
+	 *            The attribute name
+	 * @return The value, or null
+	 */
+	public Object getAttribute(final String name)
+	{
+		return attributes.get(name);
+	}
+
+	/**
+	 * Get all of the attribute names.
+	 * 
+	 * @return The attribute names
+	 */
+	public Enumeration<String> getAttributeNames()
+	{
+		return Collections.enumeration(attributes.keySet());
+	}
+
+	// ServletContext interface methods
+
+	/**
+	 * Get the context for the given URL path
+	 * 
+	 * @param name
+	 *            The url path
+	 * @return Always returns this
+	 */
+	public ServletContext getContext(String name)
+	{
+		return this;
+	}
+
+	/**
+	 * Get the init parameter with the given name.
+	 * 
+	 * @param name
+	 *            The name
+	 * @return The parameter, or null if no such parameter
+	 */
+	public String getInitParameter(final String name)
+	{
+		return initParameters.get(name);
+	}
+
+	/**
+	 * Get the name of all of the init parameters.
+	 * 
+	 * @return The init parameter names
+	 */
+	public Enumeration<String> getInitParameterNames()
+	{
+		return Collections.enumeration(initParameters.keySet());
+	}
+
+	/**
+	 * @return Always 2
+	 */
+	public int getMajorVersion()
+	{
+		return 2;
+	}
+
+	/**
+	 * Get the mime type for the given file. Uses a hardcoded map of mime types set at
+	 * Initialization time.
+	 * 
+	 * @param name
+	 *            The name to get the mime type for
+	 * @return The mime type
+	 */
+	public String getMimeType(final String name)
+	{
+		int index = name.lastIndexOf('.');
+		if (index == -1 || index == (name.length() - 1))
+		{
+			return null;
+		}
+		else
+		{
+			return mimeTypes.get(name.substring(index + 1));
+		}
+	}
+
+	/**
+	 * @return Always 3
+	 */
+	public int getMinorVersion()
+	{
+		return 3;
+	}
+
+	/**
+	 * Wicket does not use the RequestDispatcher, so this implementation just returns a dummy value.
+	 * 
+	 * @param name
+	 *            The name of the servlet or JSP
+	 * @return The dispatcher
+	 */
+	public RequestDispatcher getNamedDispatcher(final String name)
+	{
+		return getRequestDispatcher(name);
+	}
+
+	/**
+	 * Get the real file path of the given resource name.
+	 * 
+	 * @param name
+	 *            The name
+	 * @return The real path or null
+	 */
+	public String getRealPath(String name)
+	{
+		if (webappRoot == null)
+		{
+			return null;
+		}
+
+		if (name.startsWith("/"))
+		{
+			name = name.substring(1);
+		}
+
+		File f = new File(webappRoot, name);
+		if (!f.exists())
+		{
+			return null;
+		}
+		else
+		{
+			return f.getPath();
+		}
+	}
+
+	/**
+	 * Wicket does not use the RequestDispatcher, so this implementation just returns a dummy value.
+	 * 
+	 * @param name
+	 *            The name of the resource to get the dispatcher for
+	 * @return The dispatcher
+	 */
+	public RequestDispatcher getRequestDispatcher(final String name)
+	{
+		return new RequestDispatcher()
+		{
+			public void forward(ServletRequest servletRequest, ServletResponse servletResponse)
+				throws IOException
+			{
+				servletResponse.getWriter().write("FORWARD TO RESOURCE: " + name);
+			}
+
+			public void include(ServletRequest servletRequest, ServletResponse servletResponse)
+				throws IOException
+			{
+				servletResponse.getWriter().write("INCLUDE OF RESOURCE: " + name);
+			}
+		};
+	}
+
+	/**
+	 * Get the URL for a particular resource that is relative to the web app root directory.
+	 * 
+	 * @param name
+	 *            The name of the resource to get
+	 * @return The resource, or null if resource not found
+	 * @throws MalformedURLException
+	 *             If the URL is invalid
+	 */
+	public URL getResource(String name) throws MalformedURLException
+	{
+		if (webappRoot == null)
+		{
+			return null;
+		}
+
+		if (name.startsWith("/"))
+		{
+			name = name.substring(1);
+		}
+
+		File f = new File(webappRoot, name);
+		if (!f.exists())
+		{
+			return null;
+		}
+		else
+		{
+			return f.toURI().toURL();
+		}
+	}
+
+	/**
+	 * Get an input stream for a particular resource that is relative to the web app root directory.
+	 * 
+	 * @param name
+	 *            The name of the resource to get
+	 * @return The input stream for the resource, or null of resource is not found
+	 */
+	public InputStream getResourceAsStream(String name)
+	{
+		if (webappRoot == null)
+		{
+			return null;
+		}
+
+		if (name.startsWith("/"))
+		{
+			name = name.substring(1);
+		}
+
+		File f = new File(webappRoot, name);
+		if (!f.exists())
+		{
+			return null;
+		}
+		else
+		{
+			try
+			{
+				return new FileInputStream(f);
+			}
+			catch (FileNotFoundException e)
+			{
+				e.printStackTrace();
+				return null;
+			}
+		}
+	}
+
+	/**
+	 * Get the resource paths starting from the web app root directory and then relative to the the
+	 * given name.
+	 * 
+	 * @param name
+	 *            The starting name
+	 * @return The set of resource paths at this location
+	 */
+	public Set<String> getResourcePaths(String name)
+	{
+		if (webappRoot == null)
+		{
+			return new HashSet<String>();
+		}
+
+		if (name.startsWith("/"))
+		{
+			name = name.substring(1);
+		}
+		if (name.endsWith("/"))
+		{
+			name = name.substring(0, name.length() - 1);
+		}
+		String[] elements = null;
+		if (name.trim().length() == 0)
+		{
+			elements = new String[0];
+		}
+		else
+		{
+			elements = name.split("/");
+		}
+
+		File current = webappRoot;
+		for (int i = 0; i < elements.length; i++)
+		{
+			File[] files = current.listFiles();
+			boolean match = false;
+			for (int f = 0; f < files.length; f++)
+			{
+				if (files[f].getName().equals(elements[i]) && files[f].isDirectory())
+				{
+					current = files[f];
+					match = true;
+					break;
+				}
+			}
+			if (!match)
+			{
+				return null;
+			}
+		}
+
+		File[] files = current.listFiles();
+		Set<String> result = new HashSet<String>();
+		int stripLength = webappRoot.getPath().length();
+		for (int f = 0; f < files.length; f++)
+		{
+			String s = files[f].getPath().substring(stripLength).replace('\\', '/');
+			if (files[f].isDirectory())
+			{
+				s = s + "/";
+			}
+			result.add(s);
+		}
+		return result;
+	}
+
+	/**
+	 * Get the server info.
+	 * 
+	 * @return The server info
+	 */
+	public String getServerInfo()
+	{
+		return "Wicket Mock Test Environment v1.0";
+	}
+
+	/**
+	 * NOT USED - Servlet Spec requires that this always returns null.
+	 * 
+	 * @param name
+	 *            Not used
+	 * @return null
+	 * @throws ServletException
+	 *             Not used
+	 */
+	public Servlet getServlet(String name) throws ServletException
+	{
+		return null;
+	}
+
+	/**
+	 * Return the name of the servlet context.
+	 * 
+	 * @return The name
+	 */
+	public String getServletContextName()
+	{
+		return "Mock";
+	}
+
+	/**
+	 * NOT USED - Servlet spec requires that this always returns null.
+	 * 
+	 * @return null
+	 */
+	public Enumeration<String> getServletNames()
+	{
+		return null;
+	}
+
+	/**
+	 * NOT USED - Servlet spec requires that this always returns null.
+	 * 
+	 * @return null
+	 */
+	public Enumeration<Servlet> getServlets()
+	{
+		return null;
+	}
+
+	/**
+	 * As part of testing we always log to the console.
+	 * 
+	 * @param e
+	 *            The exception to log
+	 * @param msg
+	 *            The message to log
+	 */
+	public void log(Exception e, String msg)
+	{
+		//log.error(msg, e);
+	}
+
+	/**
+	 * As part of testing we always log to the console.
+	 * 
+	 * @param msg
+	 *            The message to log
+	 */
+	public void log(String msg)
+	{
+		//log.info(msg);
+	}
+
+	/**
+	 * As part of testing we always log to the console.
+	 * 
+	 * @param msg
+	 *            The message to log
+	 * @param cause
+	 *            The cause exception
+	 */
+	public void log(String msg, Throwable cause)
+	{
+		//log.error(msg, cause);
+	}
+
+	/**
+	 * Remove an attribute with the given name.
+	 * 
+	 * @param name
+	 *            The name
+	 */
+	public void removeAttribute(final String name)
+	{
+		attributes.remove(name);
+	}
+
+	/**
+	 * Set an attribute.
+	 * 
+	 * @param name
+	 *            The name of the attribute
+	 * @param o
+	 *            The value
+	 */
+	public void setAttribute(final String name, final Object o)
+	{
+		attributes.put(name, o);
+	}
+
+	/**
+	 * @return context path
+	 */
+	public String getContextPath()
+	{
+		return "";
+	}
+}

Copied: ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockServletLifecycle.java (from rev 3872, ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockServletLifecycle.java)
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockServletLifecycle.java	                        (rev 0)
+++ ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockServletLifecycle.java	2009-10-08 03:57:13 UTC (rev 3882)
@@ -0,0 +1,149 @@
+package org.jboss.weld.mock;
+
+import org.jboss.weld.bootstrap.WebBeansBootstrap;
+import org.jboss.weld.bootstrap.api.Environment;
+import org.jboss.weld.bootstrap.api.Environments;
+import org.jboss.weld.bootstrap.api.Lifecycle;
+import org.jboss.weld.bootstrap.api.helpers.ForwardingLifecycle;
+import org.jboss.weld.context.ContextLifecycle;
+import org.jboss.weld.context.api.BeanStore;
+import org.jboss.weld.context.api.helpers.ConcurrentHashMapBeanStore;
+import org.jboss.weld.resources.spi.ResourceLoader;
+import org.jboss.weld.servlet.api.ServletServices;
+
+public class MockServletLifecycle extends ForwardingLifecycle implements MockLifecycle
+{
+   private static final ResourceLoader MOCK_RESOURCE_LOADER = new MockResourceLoader();
+   
+   private final WebBeansBootstrap bootstrap;
+   private final MockDeployment deployment;
+   private final BeanStore applicationBeanStore;
+   private final BeanStore sessionBeanStore;
+   private final BeanStore requestBeanStore;
+   
+   private Lifecycle lifecycle;
+   
+   public MockServletLifecycle()
+   {
+      this.deployment = new MockDeployment();
+      if (deployment == null)
+      {
+         throw new IllegalStateException("No WebBeanDiscovery is available");
+      }
+      this.bootstrap = new WebBeansBootstrap();
+      this.deployment.getServices().add(ResourceLoader.class, MOCK_RESOURCE_LOADER);
+      this.deployment.getServices().add(ServletServices.class, new MockServletServices(deployment.getArchive()));
+      this.applicationBeanStore = new ConcurrentHashMapBeanStore();
+      this.sessionBeanStore = new ConcurrentHashMapBeanStore();
+      this.requestBeanStore = new ConcurrentHashMapBeanStore();
+   }
+   
+   protected BeanStore getSessionBeanStore()
+   {
+      return sessionBeanStore;
+   }
+   
+   protected BeanStore getRequestBeanStore()
+   {
+      return requestBeanStore;
+   }
+   
+   protected BeanStore getApplicationBeanStore()
+   {
+      return applicationBeanStore;
+   }
+   
+   /* (non-Javadoc)
+    * @see org.jboss.webbeans.mock.MockLifecycle#initialize()
+    */
+   public void initialize()
+   {
+      try
+      {
+         bootstrap.startContainer(getEnvironment(), getDeployment(), getApplicationBeanStore());
+      }
+      finally  
+      {
+         lifecycle = deployment.getServices().get(ContextLifecycle.class);
+      }
+   }
+   
+   @Override
+   protected Lifecycle delegate()
+   {
+      return lifecycle;
+   }
+   
+   protected MockDeployment getDeployment()
+   {
+      return deployment;
+   }
+   
+   protected WebBeansBootstrap getBootstrap()
+   {
+      return bootstrap;
+   }
+   
+   /* (non-Javadoc)
+    * @see org.jboss.webbeans.mock.MockLifecycle#beginApplication()
+    */
+   public void beginApplication()
+   {
+      bootstrap.startInitialization().deployBeans().validateBeans().endInitialization();
+   }
+   
+   /* (non-Javadoc)
+    * @see org.jboss.webbeans.mock.MockLifecycle#endApplication()
+    */
+   @Override
+   public void endApplication()
+   {
+      bootstrap.shutdown();
+   }
+   
+   /* (non-Javadoc)
+    * @see org.jboss.webbeans.mock.MockLifecycle#resetContexts()
+    */
+   public void resetContexts()
+   {
+      
+   }
+   
+   /* (non-Javadoc)
+    * @see org.jboss.webbeans.mock.MockLifecycle#beginRequest()
+    */
+   public void beginRequest()
+   {
+      super.beginRequest("Mock", getRequestBeanStore());
+   }
+   
+   /* (non-Javadoc)
+    * @see org.jboss.webbeans.mock.MockLifecycle#endRequest()
+    */
+   public void endRequest()
+   {
+      super.endRequest("Mock", getRequestBeanStore());
+   }
+   
+   /* (non-Javadoc)
+    * @see org.jboss.webbeans.mock.MockLifecycle#beginSession()
+    */
+   public void beginSession()
+   {
+      super.restoreSession("Mock", getSessionBeanStore());
+   }
+   
+   /* (non-Javadoc)
+    * @see org.jboss.webbeans.mock.MockLifecycle#endSession()
+    */
+   public void endSession()
+   {
+      // TODO Conversation handling breaks this :-(
+      //super.endSession("Mock", sessionBeanStore);
+   }
+   
+   protected Environment getEnvironment()
+   {
+      return Environments.SERVLET;
+   }
+}

Copied: ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockServletServices.java (from rev 3872, ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockServletServices.java)
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockServletServices.java	                        (rev 0)
+++ ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockServletServices.java	2009-10-08 03:57:13 UTC (rev 3882)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.mock;
+
+import javax.servlet.ServletContext;
+
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.weld.servlet.api.ServletServices;
+
+/**
+ * @author pmuir
+ *
+ */
+public class MockServletServices implements ServletServices
+{
+
+   private final BeanDeploymentArchive beanDeploymentArchive;
+   
+   public MockServletServices(BeanDeploymentArchive beanDeploymentArchive)
+   {
+      this.beanDeploymentArchive = beanDeploymentArchive;
+   }
+
+   public BeanDeploymentArchive getBeanDeploymentArchive(ServletContext ctx)
+   {
+      if (ctx instanceof MockServletContext)
+      {
+         return beanDeploymentArchive;
+      }
+      else
+      {
+         return null;
+      }
+   }
+   
+   public void cleanup() {}
+
+}

Copied: ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockTransactionServices.java (from rev 3872, ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockTransactionServices.java)
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockTransactionServices.java	                        (rev 0)
+++ ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockTransactionServices.java	2009-10-08 03:57:13 UTC (rev 3882)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.weld.mock;
+
+import javax.transaction.Synchronization;
+import javax.transaction.UserTransaction;
+
+import org.jboss.weld.transaction.spi.TransactionServices;
+
+/**
+ * A mock version of TransactionServices for RI unit tests.  Since
+ * no JTA transaction can be active for these unit tests, all
+ * methods here are empty.
+ * 
+ * @author David Allen
+ *
+ */
+public class MockTransactionServices implements TransactionServices
+{
+
+   public boolean isTransactionActive()
+   {
+      return false;
+   }
+
+   public void registerSynchronization(Synchronization synchronizedObserver)
+   {
+   }
+   
+   public UserTransaction getUserTransaction()
+   {
+      return null;
+   }
+   
+   public void cleanup() {}
+
+}

Copied: ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockValidationServices.java (from rev 3872, ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockValidationServices.java)
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockValidationServices.java	                        (rev 0)
+++ ri/trunk/tests/src/main/java/org/jboss/weld/mock/MockValidationServices.java	2009-10-08 03:57:13 UTC (rev 3882)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.mock;
+
+import javax.validation.ValidatorFactory;
+
+import org.jboss.weld.validation.spi.ValidationServices;
+
+/**
+ * @author pmuir
+ *
+ */
+public class MockValidationServices implements ValidationServices
+{
+
+   public ValidatorFactory getDefaultValidatorFactory()
+   {
+      return null;
+   }
+   
+   public void cleanup() {}
+
+}

Copied: ri/trunk/tests/src/main/java/org/jboss/weld/mock/TestContainer.java (from rev 3872, ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/TestContainer.java)
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/weld/mock/TestContainer.java	                        (rev 0)
+++ ri/trunk/tests/src/main/java/org/jboss/weld/mock/TestContainer.java	2009-10-08 03:57:13 UTC (rev 3882)
@@ -0,0 +1,143 @@
+package org.jboss.weld.mock;
+
+import java.net.URL;
+import java.util.Collection;
+
+import org.jboss.weld.BeanManagerImpl;
+
+/**
+ * Control of the container, used for tests. Wraps up common operations.
+ * 
+ * @author pmuir
+ *
+ */
+public class TestContainer
+{
+   
+   public static class Status
+   {
+      
+      private final Exception deploymentException;
+
+      public Status(Exception deploymentException)
+      {
+         this.deploymentException = deploymentException;
+      }
+      
+      public Exception getDeploymentException()
+      {
+         return deploymentException;
+      }
+      
+      public boolean isSuccess()
+      {
+         return deploymentException == null;
+      }
+      
+   }
+   
+   private final MockServletLifecycle lifecycle;
+   private final Collection<Class<?>> classes;
+   private final Collection<URL> beansXml;
+
+   /**
+    * Create a container, specifying the classes and beans.xml to deploy
+    * 
+    * @param lifecycle
+    * @param classes
+    * @param beansXml
+    */
+   public TestContainer(MockServletLifecycle lifecycle, Collection<Class<?>> classes, Collection<URL> beansXml)
+   {
+      this.lifecycle = lifecycle;
+      this.classes = classes;
+      this.beansXml = beansXml;
+   }
+   
+   /**
+    * Start the container, returning the container state
+    * 
+    * @return
+    */
+   public Status startContainerAndReturnStatus()
+   {
+      try
+      {
+         startContainer();
+      }
+      catch (Exception e) 
+      {
+         return new Status(e);
+      }
+      return new Status(null);
+   }
+   
+   public void startContainer()
+   {
+      MockBeanDeploymentArchive archive = lifecycle.getDeployment().getArchive();
+      archive.setBeanClasses(classes);
+      if (beansXml != null)
+      {
+         archive.setBeansXmlFiles(beansXml);
+      }
+      lifecycle.initialize();
+      lifecycle.beginApplication();
+   }
+   
+   /**
+    * Get the context lifecycle, allowing fine control over the contexts' state
+    * 
+    * @return
+    */
+   public MockServletLifecycle getLifecycle()
+   {
+      return lifecycle;
+   }
+   
+   public BeanManagerImpl getBeanManager()
+   {
+      return lifecycle.getBootstrap().getManager(getDeployment().getArchive());
+   }
+   
+   public MockDeployment getDeployment()
+   {
+      return lifecycle.getDeployment();
+   }
+   
+   /**
+    * Utility method which ensures a request is active and available for use
+    * 
+    */
+   public void ensureRequestActive()
+   {
+      if (!lifecycle.isSessionActive())
+      {
+         lifecycle.beginSession();
+      }
+      if (!lifecycle.isRequestActive())
+      {
+         lifecycle.beginRequest();
+      }
+   }
+
+   /**
+    * Clean up the container, ending any active contexts
+    * 
+    */
+   public void stopContainer()
+   {
+      if (lifecycle.isRequestActive())
+      {
+         lifecycle.endRequest();
+      }
+      if (lifecycle.isSessionActive())
+      {
+         lifecycle.endSession();
+      }
+      if (lifecycle.isApplicationActive())
+      {
+         lifecycle.endApplication();
+      }
+   }
+
+}
\ No newline at end of file

Copied: ri/trunk/tests/src/main/java/org/jboss/weld/mock/cluster (from rev 3872, ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/cluster)

Modified: ri/trunk/tests/src/main/java/org/jboss/weld/mock/cluster/AbstractClusterTest.java
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/cluster/AbstractClusterTest.java	2009-10-07 21:43:49 UTC (rev 3872)
+++ ri/trunk/tests/src/main/java/org/jboss/weld/mock/cluster/AbstractClusterTest.java	2009-10-08 03:57:13 UTC (rev 3882)
@@ -1,4 +1,4 @@
-package org.jboss.webbeans.mock.cluster;
+package org.jboss.weld.mock.cluster;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -7,12 +7,12 @@
 import java.io.ObjectOutputStream;
 import java.util.Collection;
 
-import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.bootstrap.api.SingletonProvider;
-import org.jboss.webbeans.context.ContextLifecycle;
-import org.jboss.webbeans.context.api.BeanStore;
-import org.jboss.webbeans.mock.MockEELifecycle;
-import org.jboss.webbeans.mock.TestContainer;
+import org.jboss.weld.BeanManagerImpl;
+import org.jboss.weld.bootstrap.api.SingletonProvider;
+import org.jboss.weld.context.ContextLifecycle;
+import org.jboss.weld.context.api.BeanStore;
+import org.jboss.weld.mock.MockEELifecycle;
+import org.jboss.weld.mock.TestContainer;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 

Modified: ri/trunk/tests/src/main/java/org/jboss/weld/mock/cluster/SwitchableMockEELifecycle.java
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/cluster/SwitchableMockEELifecycle.java	2009-10-07 21:43:49 UTC (rev 3872)
+++ ri/trunk/tests/src/main/java/org/jboss/weld/mock/cluster/SwitchableMockEELifecycle.java	2009-10-08 03:57:13 UTC (rev 3882)
@@ -1,10 +1,10 @@
-package org.jboss.webbeans.mock.cluster;
+package org.jboss.weld.mock.cluster;
 
 import java.util.HashMap;
 import java.util.Map;
 
-import org.jboss.webbeans.context.api.BeanStore;
-import org.jboss.webbeans.mock.MockEELifecycle;
+import org.jboss.weld.context.api.BeanStore;
+import org.jboss.weld.mock.MockEELifecycle;
 
 public class SwitchableMockEELifecycle extends MockEELifecycle
 {

Modified: ri/trunk/tests/src/main/java/org/jboss/weld/mock/cluster/SwitchableSingletonProvider.java
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/cluster/SwitchableSingletonProvider.java	2009-10-07 21:43:49 UTC (rev 3872)
+++ ri/trunk/tests/src/main/java/org/jboss/weld/mock/cluster/SwitchableSingletonProvider.java	2009-10-08 03:57:13 UTC (rev 3882)
@@ -1,10 +1,10 @@
-package org.jboss.webbeans.mock.cluster;
+package org.jboss.weld.mock.cluster;
 
 import java.util.Hashtable;
 import java.util.Map;
 
-import org.jboss.webbeans.bootstrap.api.Singleton;
-import org.jboss.webbeans.bootstrap.api.SingletonProvider;
+import org.jboss.weld.bootstrap.api.Singleton;
+import org.jboss.weld.bootstrap.api.SingletonProvider;
 
 public class SwitchableSingletonProvider extends SingletonProvider
 {

Copied: ri/trunk/tests/src/main/java/org/jboss/weld/mock/el (from rev 3872, ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/el)

Modified: ri/trunk/tests/src/main/java/org/jboss/weld/mock/el/EL.java
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/el/EL.java	2009-10-07 21:43:49 UTC (rev 3872)
+++ ri/trunk/tests/src/main/java/org/jboss/weld/mock/el/EL.java	2009-10-08 03:57:13 UTC (rev 3882)
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jboss.webbeans.mock.el;
+package org.jboss.weld.mock.el;
 
 import javax.el.ArrayELResolver;
 import javax.el.BeanELResolver;
@@ -30,9 +30,9 @@
 import javax.el.ResourceBundleELResolver;
 import javax.el.VariableMapper;
 
-import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.el.WebBeansELContextListener;
-import org.jboss.webbeans.el.WebBeansExpressionFactory;
+import org.jboss.weld.BeanManagerImpl;
+import org.jboss.weld.el.WebBeansELContextListener;
+import org.jboss.weld.el.WebBeansExpressionFactory;
 
 import com.sun.el.ExpressionFactoryImpl;
 import com.sun.el.lang.FunctionMapperImpl;

Copied: ri/trunk/tests/src/main/java/org/jboss/weld/test/AbstractWebBeansTest.java (from rev 3872, ri/trunk/tests/src/main/java/org/jboss/webbeans/test/AbstractWebBeansTest.java)
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/weld/test/AbstractWebBeansTest.java	                        (rev 0)
+++ ri/trunk/tests/src/main/java/org/jboss/weld/test/AbstractWebBeansTest.java	2009-10-08 03:57:13 UTC (rev 3882)
@@ -0,0 +1,204 @@
+package org.jboss.weld.test;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
+import javax.el.ELContext;
+import javax.enterprise.inject.TypeLiteral;
+import javax.enterprise.inject.spi.Bean;
+import javax.servlet.ServletContext;
+
+import org.jboss.testharness.AbstractTest;
+import org.jboss.testharness.impl.runner.servlet.ServletTestRunner;
+import org.jboss.weld.BeanManagerImpl;
+import org.jboss.weld.mock.MockServletContext;
+import org.jboss.weld.mock.el.EL;
+import org.jboss.weld.servlet.ServletHelper;
+import org.jboss.weld.util.collections.EnumerationList;
+import org.testng.ITestContext;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeSuite;
+
+public abstract class AbstractWebBeansTest extends AbstractTest
+{
+   
+   private ServletContext servletContext;
+
+   @Override
+   @BeforeSuite
+   public void beforeSuite(ITestContext context) throws Exception
+   {
+      if (!isInContainer())
+      {
+         getCurrentConfiguration().getExtraPackages().add(AbstractWebBeansTest.class.getPackage().getName());
+         getCurrentConfiguration().getExtraPackages().add(EL.class.getPackage().getName());
+         //getCurrentConfiguration().getExtraPackages().add(MockServletContext.class.getPackage().getName());
+      }
+      super.beforeSuite(context);
+   }
+   
+   @Override
+   @BeforeClass
+   public void beforeClass() throws Throwable
+   {
+      super.beforeClass();
+      if (isInContainer())
+      {
+         servletContext = ServletTestRunner.getCurrentServletContext();
+      }
+      else
+      {
+         servletContext = new MockServletContext("");
+      }
+      
+   }
+   
+   @Override
+   @AfterClass
+   public void afterClass() throws Exception
+   {
+      servletContext = null;
+      super.afterClass();
+   }
+
+   /**
+    * Checks if all annotations are in a given set of annotations
+    * 
+    * @param annotations The annotation set
+    * @param annotationTypes The annotations to match
+    * @return True if match, false otherwise
+    */
+   public boolean annotationSetMatches(Set<? extends Annotation> annotations, Class<? extends Annotation>... annotationTypes)
+   {
+      List<Class<? extends Annotation>> annotationTypeList = new ArrayList<Class<? extends Annotation>>();
+      annotationTypeList.addAll(Arrays.asList(annotationTypes));
+      for (Annotation annotation : annotations)
+      {
+         if (annotationTypeList.contains(annotation.annotationType()))
+         {
+            annotationTypeList.remove(annotation.annotationType());
+         }
+         else
+         {
+            return false;
+         }
+      }
+      return annotationTypeList.size() == 0;
+   }
+
+   protected Iterable<URL> getResources(String name)
+   {
+      if (name.startsWith("/"))
+      {
+         name = name.substring(1);
+      }
+      else
+      {
+         name = getClass().getPackage().getName().replace(".", "/") + "/" + name;
+      }
+      try
+      {
+         return new EnumerationList<URL>(getClass().getClassLoader().getResources(name));
+      }
+      catch (IOException e)
+      {
+         throw new RuntimeException("Error loading resource from classloader" + name, e);
+      }
+   }
+
+   protected byte[] serialize(Object instance) throws IOException
+   {
+      ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+      ObjectOutputStream out = new ObjectOutputStream(bytes);
+      out.writeObject(instance);
+      return bytes.toByteArray();
+   }
+
+   protected Object deserialize(byte[] bytes) throws IOException, ClassNotFoundException
+   {
+      ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes));
+      return in.readObject();
+   }
+
+   protected BeanManagerImpl getCurrentManager()
+   {
+      return ServletHelper.getModuleBeanManager(servletContext);
+   }
+
+   public boolean isExceptionInHierarchy(Throwable exception, Class<? extends Throwable> expectedException )
+   {
+      while (exception != null)
+      {
+         if (exception.getClass().equals(expectedException))
+         {
+            return true;
+         }
+         exception = exception.getCause();
+      }
+      return false;
+   }
+
+   public <T> Bean<T> getBean(Type beanType, Annotation... bindings)
+   {
+      Set<Bean<?>> beans = getCurrentManager().getBeans(beanType, bindings);
+      if (beans.size() > 1)
+      {
+         throw new RuntimeException("More than one bean resolved to " + beanType + " with bindings " + Arrays.asList(bindings));
+      }
+      if (beans.size() == 0)
+      {
+         throw new RuntimeException("No beans resolved to " + beanType + " with bindings " + Arrays.asList(bindings));
+      }
+      @SuppressWarnings("unchecked")
+      Bean<T> bean = (Bean<T>) beans.iterator().next();
+      return bean;
+   }
+
+   @SuppressWarnings("unchecked")
+   public <T> Set<Bean<T>> getBeans(Class<T> type, Annotation... bindings)
+   {
+      return (Set) getCurrentManager().getBeans(type, bindings);
+   }
+
+   @SuppressWarnings("unchecked")
+   public <T> Set<Bean<T>> getBeans(TypeLiteral<T> type, Annotation... bindings)
+   {
+      return (Set)getCurrentManager().getBeans(type.getType(), bindings);
+   }
+
+   @SuppressWarnings("unchecked")
+   public <T> T createContextualInstance(Class<T> beanType, Annotation... bindings)
+   {
+      return (T) createContextualInstance((Type) beanType, bindings);
+   }
+
+   public Object createContextualInstance(Type beanType, Annotation... bindings)
+   {
+      Bean<?> bean = getBean(beanType, bindings);
+      return getCurrentManager().getReference(bean, beanType, getCurrentManager().createCreationalContext(bean));
+   }
+
+   @SuppressWarnings("unchecked")
+   public <T> T evaluateValueExpression(String expression, Class<T> expectedType)
+   {
+      ELContext elContext = EL.createELContext(getCurrentManager().getCurrent());
+      return (T) EL.EXPRESSION_FACTORY.createValueExpression(elContext, expression, expectedType).getValue(elContext);
+   }
+   
+   protected String getPath(String viewId)
+   {
+      return getContextPath() + viewId;
+   }
+
+}

Copied: ri/trunk/tests/src/main/java/org/jboss/weld/test/harness (from rev 3872, ri/trunk/tests/src/main/java/org/jboss/webbeans/test/harness)

Modified: ri/trunk/tests/src/main/java/org/jboss/weld/test/harness/AbstractStandaloneContainersImpl.java
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/webbeans/test/harness/AbstractStandaloneContainersImpl.java	2009-10-07 21:43:49 UTC (rev 3872)
+++ ri/trunk/tests/src/main/java/org/jboss/weld/test/harness/AbstractStandaloneContainersImpl.java	2009-10-08 03:57:13 UTC (rev 3882)
@@ -1,13 +1,13 @@
-package org.jboss.webbeans.test.harness;
+package org.jboss.weld.test.harness;
 
 import java.net.URL;
 import java.util.Collection;
 
 import org.jboss.testharness.api.DeploymentException;
 import org.jboss.testharness.spi.StandaloneContainers;
-import org.jboss.webbeans.mock.MockServletLifecycle;
-import org.jboss.webbeans.mock.TestContainer;
-import org.jboss.webbeans.mock.TestContainer.Status;
+import org.jboss.weld.mock.MockServletLifecycle;
+import org.jboss.weld.mock.TestContainer;
+import org.jboss.weld.mock.TestContainer.Status;
 
 public abstract class AbstractStandaloneContainersImpl implements StandaloneContainers
 {

Modified: ri/trunk/tests/src/main/java/org/jboss/weld/test/harness/ServletLifecycleContainersImpl.java
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/webbeans/test/harness/ServletLifecycleContainersImpl.java	2009-10-07 21:43:49 UTC (rev 3872)
+++ ri/trunk/tests/src/main/java/org/jboss/weld/test/harness/ServletLifecycleContainersImpl.java	2009-10-08 03:57:13 UTC (rev 3882)
@@ -1,6 +1,6 @@
-package org.jboss.webbeans.test.harness;
+package org.jboss.weld.test.harness;
 
-import org.jboss.webbeans.mock.MockServletLifecycle;
+import org.jboss.weld.mock.MockServletLifecycle;
 
 public class ServletLifecycleContainersImpl extends AbstractStandaloneContainersImpl
 {

Modified: ri/trunk/tests/src/main/java/org/jboss/weld/test/harness/StandaloneContainersImpl.java
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/webbeans/test/harness/StandaloneContainersImpl.java	2009-10-07 21:43:49 UTC (rev 3872)
+++ ri/trunk/tests/src/main/java/org/jboss/weld/test/harness/StandaloneContainersImpl.java	2009-10-08 03:57:13 UTC (rev 3882)
@@ -1,8 +1,8 @@
-package org.jboss.webbeans.test.harness;
+package org.jboss.weld.test.harness;
 
 import org.jboss.testharness.spi.StandaloneContainers;
-import org.jboss.webbeans.mock.MockEELifecycle;
-import org.jboss.webbeans.mock.MockServletLifecycle;
+import org.jboss.weld.mock.MockEELifecycle;
+import org.jboss.weld.mock.MockServletLifecycle;
 
 public class StandaloneContainersImpl extends AbstractStandaloneContainersImpl implements StandaloneContainers
 {



More information about the weld-commits mailing list