You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2006/11/21 22:49:12 UTC

svn commit: r477910 [2/9] - in /tapestry/tapestry5: tapestry-core/trunk/ tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/bindings/ tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/test/ tapestry-core/trunk/src/main/resource...

Modified: tapestry/tapestry5/tapestry-core/trunk/pom.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/pom.xml?view=diff&rev=477910&r1=477909&r2=477910
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/pom.xml (original)
+++ tapestry/tapestry5/tapestry-core/trunk/pom.xml Tue Nov 21 13:48:47 2006
@@ -5,7 +5,6 @@
     <artifactId>tapestry-core</artifactId>
     <packaging>jar</packaging>
     <version>5.0.0-SNAPSHOT</version>
-    <!-- This should change to tapestry-project -->
     <parent>
         <groupId>org.apache.tapestry</groupId>
         <artifactId>tapestry-project</artifactId>
@@ -17,35 +16,24 @@
     <url>http://tapestry.apache.org/tapestry5/</url>
     <dependencies>
         <dependency>
-            <groupId>javassist</groupId>
-            <artifactId>javassist</artifactId>
-            <!-- Override parent pom -->
-            <scope>compile</scope>
-        </dependency>
-        <dependency>
-            <groupId>commons-logging</groupId>
-            <artifactId>commons-logging</artifactId>
+            <groupId>org.apache.tapestry</groupId>
+            <artifactId>tapestry-ioc</artifactId>
         </dependency>
         <dependency>
             <groupId>commons-codec</groupId>
             <artifactId>commons-codec</artifactId>
             <version>1.3</version>
         </dependency>
-        <!-- Override parent pom: needed at compile time. -->
         <dependency>
             <groupId>org.easymock</groupId>
             <artifactId>easymock</artifactId>
-            <scope>provided</scope>
         </dependency>
-        <!-- Override parent pom: needed at compile time. -->
         <dependency>
             <groupId>org.testng</groupId>
             <artifactId>testng</artifactId>
-            <!-- Looks like if you override scope, you have to provide version (and classifier) as well.
-                Or perhaps this has something to do with classifier. -->
             <version>5.1</version>
             <classifier>jdk15</classifier>
-            <scope>provided</scope>
+            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>javax.servlet</groupId>
@@ -63,14 +51,6 @@
             <groupId>org.openqa.selenium.server</groupId>
             <artifactId>selenium-server</artifactId>
         </dependency>
-        <!-- 
-        <dependency>
-            <groupId>org.mortbay.jetty</groupId>
-            <artifactId>jetty</artifactId>
-            <version>6.0.0beta10</version>
-            <classifier>standalone</classifier>
-            <scope>test</scope>
-        </dependency> -->
     </dependencies>
     <build>
         <plugins>

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/bindings/PropBindingFactory.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/bindings/PropBindingFactory.java?view=diff&rev=477910&r1=477909&r2=477910
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/bindings/PropBindingFactory.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/bindings/PropBindingFactory.java Tue Nov 21 13:48:47 2006
@@ -244,7 +244,7 @@
 
             if (propertyType.isPrimitive())
             {
-                String wrapperType = ClassFabUtils.getWrapperType(propertyTypeName);
+                String wrapperType = ClassFabUtils.getWrapperTypeName(propertyTypeName);
                 String unwrapMethod = ClassFabUtils.getUnwrapMethodName(propertyTypeName);
 
                 // Cast the value to the wrapper type, and then extract the primitive

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java?view=diff&rev=477910&r1=477909&r2=477910
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java Tue Nov 21 13:48:47 2006
@@ -14,13 +14,11 @@
 
 package org.apache.tapestry.internal.test;
 
-import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newList;
 import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newSet;
 import static org.easymock.EasyMock.eq;
 import static org.easymock.EasyMock.isA;
 
 import java.util.Arrays;
-import java.util.List;
 import java.util.Locale;
 
 import org.apache.commons.logging.Log;
@@ -40,14 +38,9 @@
 import org.apache.tapestry.internal.structure.Page;
 import org.apache.tapestry.internal.structure.PageElement;
 import org.apache.tapestry.ioc.Location;
-import org.apache.tapestry.ioc.ObjectProvider;
 import org.apache.tapestry.ioc.Registry;
 import org.apache.tapestry.ioc.RegistryBuilder;
 import org.apache.tapestry.ioc.Resource;
-import org.apache.tapestry.ioc.ServiceDecorator;
-import org.apache.tapestry.ioc.ServiceLifecycle;
-import org.apache.tapestry.ioc.ServiceLocator;
-import org.apache.tapestry.ioc.def.ServiceDef;
 import org.apache.tapestry.ioc.internal.InternalRegistry;
 import org.apache.tapestry.ioc.internal.Module;
 import org.apache.tapestry.model.ComponentModel;
@@ -68,7 +61,6 @@
 /**
  * Contains additional factory and training methods related to internal interfaces.
  */
-
 public class InternalBaseTestCase extends TapestryTestCase implements Registry
 {
     private static Registry _registry;
@@ -135,56 +127,6 @@
         registry.getService(serviceId, serviceInterface, module);
         setReturnValue(service);
 
-    }
-
-    protected final void train_getLifecycle(InternalRegistry registry, String name,
-            ServiceLifecycle lifecycle)
-    {
-        registry.getServiceLifecycle(name);
-        setReturnValue(lifecycle);
-    }
-
-    protected final void train_findDecoratorsForService(Module module, String serviceId,
-            List<ServiceDecorator> decorators)
-    {
-        module.findDecoratorsForService(serviceId);
-        setReturnValue(decorators);
-    }
-
-    protected final void train_findDecoratorsForService(InternalRegistry registry)
-    {
-        registry.findDecoratorsForService(isA(ServiceDef.class));
-        setReturnValue(newList());
-    }
-
-    protected final InternalRegistry newInternalRegistry()
-    {
-        return newMock(InternalRegistry.class);
-    }
-
-    protected final Registry buildRegistry(Class... moduleClasses)
-    {
-        RegistryBuilder builder = new RegistryBuilder();
-        builder.add(moduleClasses);
-
-        return builder.build();
-    }
-
-    protected final ObjectProvider newObjectProvider()
-    {
-        return newMock(ObjectProvider.class);
-    }
-
-    protected final <T> void train_provide(ObjectProvider provider, String expression,
-            Class<T> objectType, ServiceLocator locator, T object)
-    {
-        provider.provide(expression, objectType, locator);
-        setReturnValue(object);
-    }
-
-    protected final Module newModule()
-    {
-        return newMock(Module.class);
     }
 
     protected final ComponentInstantiatorSource newComponentInstantiatorSource()

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/conf/testng.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/conf/testng.xml?view=diff&rev=477910&r1=477909&r2=477910
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/conf/testng.xml (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/conf/testng.xml Tue Nov 21 13:48:47 2006
@@ -15,11 +15,9 @@
    limitations under the License.
 -->
 
-<suite name="Tapestry" parallel="false" thread-count="10" annotations="1.5" verbose="2">
+<suite name="Tapestry Core" parallel="false" thread-count="10" annotations="1.5" verbose="2">
   <test name="Tapestry Core">
     <packages>
-      <!-- Logically we'd like to do the General (unit) testing first, but practically,
-        it's great to have it all run in parallel. -->
       <package name="org.apache.tapestry.integration"/>
       <package name="org.apache.tapestry"/>
       <package name="org.apache.tapestry.dom"/>
@@ -28,12 +26,6 @@
       <package name="org.apache.tapestry.internal.services"/>
       <package name="org.apache.tapestry.internal.structure"/>
       <package name="org.apache.tapestry.internal.util"/>
-      <package name="org.apache.tapestry.ioc"/>
-      <package name="org.apache.tapestry.ioc.services"/>
-      <package name="org.apache.tapestry.ioc.util"/>
-      <package name="org.apache.tapestry.ioc.internal"/>
-      <package name="org.apache.tapestry.ioc.internal.services"/>
-      <package name="org.apache.tapestry.ioc.internal.util"/>
       <package name="org.apache.tapestry.services"/>
       <package name="org.apache.tapestry.util"/>
       <package name="org.apache.tapestry.runtime"/>

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java?view=diff&rev=477910&r1=477909&r2=477910
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java Tue Nov 21 13:48:47 2006
@@ -204,7 +204,7 @@
 
         clickAndWait("link=BadTemplate Page");
 
-        assertTextPresent("org.apache.tapestry.internal.TapestryException");
+        assertTextPresent("org.apache.tapestry.ioc.internal.util.TapestryException");
         assertTextPresent("Failure parsing template classpath:org/apache/tapestry/integration/app1/pages/BadTemplate.html");
         assertTextPresent("org.xml.sax.SAXParseException");
         assertTextPresent("XML document structures must start and end within the same entity.");

Modified: tapestry/tapestry5/tapestry-ioc/trunk/.classpath
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/.classpath?view=diff&rev=477910&r1=477909&r2=477910
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/.classpath (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/.classpath Tue Nov 21 13:48:47 2006
@@ -5,5 +5,6 @@
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="lib" path="src/main/resources"/>
 	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="lib" path="src/test/resources"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>

Modified: tapestry/tapestry5/tapestry-ioc/trunk/pom.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/pom.xml?view=diff&rev=477910&r1=477909&r2=477910
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/pom.xml (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/pom.xml Tue Nov 21 13:48:47 2006
@@ -26,11 +26,6 @@
             <groupId>commons-logging</groupId>
             <artifactId>commons-logging</artifactId>
         </dependency>
-        <dependency>
-            <groupId>commons-codec</groupId>
-            <artifactId>commons-codec</artifactId>
-            <version>1.3</version>
-        </dependency>
         <!-- Override parent pom: needed at compile time. -->
         <dependency>
             <groupId>org.easymock</groupId>
@@ -48,29 +43,9 @@
             <scope>provided</scope>
         </dependency>
         <dependency>
-            <groupId>javax.servlet</groupId>
-            <artifactId>servlet-api</artifactId>
-        </dependency>
-        <dependency>
             <groupId>log4j</groupId>
             <artifactId>log4j</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.openqa.selenium.client-drivers</groupId>
-            <artifactId>selenium-java-client-driver</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.openqa.selenium.server</groupId>
-            <artifactId>selenium-server</artifactId>
-        </dependency>
-        <!-- 
-        <dependency>
-            <groupId>org.mortbay.jetty</groupId>
-            <artifactId>jetty</artifactId>
-            <version>6.0.0beta10</version>
-            <classifier>standalone</classifier>
-            <scope>test</scope>
-        </dependency> -->
     </dependencies>
     <build>
         <plugins>
@@ -90,7 +65,6 @@
                     <source>1.5</source>
                     <target>1.5</target>
                     <optimize>true</optimize>
-                    <verbose>true</verbose>
                 </configuration>
             </plugin>          
         </plugins>

Added: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/IOCInternalTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/IOCInternalTestCase.java?view=auto&rev=477910
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/IOCInternalTestCase.java (added)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/IOCInternalTestCase.java Tue Nov 21 13:48:47 2006
@@ -0,0 +1,102 @@
+package org.apache.tapestry.ioc.internal;
+
+import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newList;
+import static org.easymock.EasyMock.isA;
+
+import java.util.List;
+
+import org.apache.tapestry.ioc.Registry;
+import org.apache.tapestry.ioc.RegistryBuilder;
+import org.apache.tapestry.ioc.ServiceDecorator;
+import org.apache.tapestry.ioc.ServiceLifecycle;
+import org.apache.tapestry.ioc.def.ServiceDef;
+import org.apache.tapestry.ioc.test.IOCTestCase;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.AfterSuite;
+import org.testng.annotations.BeforeSuite;
+
+public class IOCInternalTestCase extends IOCTestCase implements Registry
+{
+    private static Registry _registry;
+
+    @BeforeSuite
+    public final void setup_registry()
+    {
+        RegistryBuilder builder = new RegistryBuilder();
+
+        _registry = builder.build();
+    }
+
+    @AfterSuite
+    public final void shutdown_registry()
+    {
+        _registry.shutdown();
+
+        _registry = null;
+    }
+
+    @AfterMethod
+    public final void cleanupThread()
+    {
+        _registry.cleanupThread();
+    }
+
+    public final <T> T getObject(String reference, Class<T> objectType)
+    {
+        return _registry.getObject(reference, objectType);
+    }
+
+    public final <T> T getService(Class<T> serviceInterface)
+    {
+        return _registry.getService(serviceInterface);
+    }
+
+    public final <T> T getService(String serviceId, Class<T> serviceInterface)
+    {
+        return _registry.getService(serviceId, serviceInterface);
+    }
+
+    public final void shutdown()
+    {
+        throw new UnsupportedOperationException("No registry shutdown until @AfterSuite.");
+    }
+
+    protected final void train_findDecoratorsForService(Module module, String serviceId,
+            List<ServiceDecorator> decorators)
+    {
+        module.findDecoratorsForService(serviceId);
+        setReturnValue(decorators);
+    }
+
+    protected final void train_findDecoratorsForService(InternalRegistry registry)
+    {
+        registry.findDecoratorsForService(isA(ServiceDef.class));
+        setReturnValue(newList());
+
+    }
+
+    protected final InternalRegistry newInternalRegistry()
+    {
+        return newMock(InternalRegistry.class);
+    }
+
+    protected final void train_getLifecycle(InternalRegistry registry, String name,
+            ServiceLifecycle lifecycle)
+    {
+        registry.getServiceLifecycle(name);
+        setReturnValue(lifecycle);
+    }
+
+    protected final <T> void train_getService(InternalRegistry registry, String serviceId,
+            Class<T> serviceInterface, Module module, T service)
+    {
+        registry.getService(serviceId, serviceInterface, module);
+        setReturnValue(service);
+    }
+
+    protected final Module newModule()
+    {
+        return newMock(Module.class);
+    }
+
+}

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/TypeCoercerImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/TypeCoercerImpl.java?view=diff&rev=477910&r1=477909&r2=477910
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/TypeCoercerImpl.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/TypeCoercerImpl.java Tue Nov 21 13:48:47 2006
@@ -29,6 +29,7 @@
 import org.apache.tapestry.ioc.internal.util.Defense;
 import org.apache.tapestry.ioc.internal.util.InheritanceSearch;
 import org.apache.tapestry.ioc.internal.util.InternalUtils;
+import org.apache.tapestry.ioc.services.ClassFabUtils;
 import org.apache.tapestry.ioc.services.Coercion;
 import org.apache.tapestry.ioc.services.CoercionTuple;
 import org.apache.tapestry.ioc.services.TypeCoercer;
@@ -120,7 +121,7 @@
         // The caller may ask for the value in a primitive type, but the best we can do is the
         // equivalent wrapper type.
 
-        Class effectiveTargetType = sourceType; // ClassFabUtils.getWrapperType(targetType);
+        Class effectiveTargetType = ClassFabUtils.getWrapperType(targetType);
 
         // Is a coercion even necessary? Not if the target type is assignable from the
         // input value.

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/ClassFabUtils.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/ClassFabUtils.java?view=diff&rev=477910&r1=477909&r2=477910
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/ClassFabUtils.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/ClassFabUtils.java Tue Nov 21 13:48:47 2006
@@ -174,8 +174,20 @@
 
     /** Given the name of a primitive type, returns the name of the corresponding wrapper class. */
 
-    public static String getWrapperType(String primitiveType)
+    public static String getWrapperTypeName(String primitiveType)
     {
         return PRIMITIVE_INFO.get(primitiveType).getWrapperType().getName();
+    }
+
+    /**
+     * Given some type (possibly a primitive) returns the corresponding primitive type. For
+     * non-primitives, the provided type is returned.
+     */
+    public static Class getWrapperType(Class primitiveType)
+    {
+        if (primitiveType.isPrimitive())
+            return PRIMITIVE_INFO.get(primitiveType.getName()).getWrapperType();
+
+        return primitiveType; // Not a primitive!
     }
 }

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/test/IOCTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/test/IOCTestCase.java?view=diff&rev=477910&r1=477909&r2=477910
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/test/IOCTestCase.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/test/IOCTestCase.java Tue Nov 21 13:48:47 2006
@@ -8,7 +8,10 @@
 import org.apache.tapestry.ioc.LogSource;
 import org.apache.tapestry.ioc.MappedConfiguration;
 import org.apache.tapestry.ioc.ObjectCreator;
+import org.apache.tapestry.ioc.ObjectProvider;
 import org.apache.tapestry.ioc.OrderedConfiguration;
+import org.apache.tapestry.ioc.Registry;
+import org.apache.tapestry.ioc.RegistryBuilder;
 import org.apache.tapestry.ioc.Resource;
 import org.apache.tapestry.ioc.ServiceBuilderResources;
 import org.apache.tapestry.ioc.ServiceDecorator;
@@ -18,17 +21,65 @@
 import org.apache.tapestry.ioc.def.DecoratorDef;
 import org.apache.tapestry.ioc.def.ModuleDef;
 import org.apache.tapestry.ioc.def.ServiceDef;
+import org.apache.tapestry.ioc.services.ClassFactory;
 import org.apache.tapestry.ioc.services.TypeCoercer;
 
 /** Add factory and trainer methods for the public interfaces of Tapestry IOC. */
 public class IOCTestCase extends TestBase
 {
+    protected final Registry buildRegistry(Class... moduleClasses)
+    {
+        RegistryBuilder builder = new RegistryBuilder();
+
+        builder.add(moduleClasses);
+
+        return builder.build();
+    }
+
+    protected final Method findMethod(Class clazz, String methodName)
+    {
+        for (Method method : clazz.getMethods())
+        {
+            if (method.getName().equals(methodName)) return method;
+        }
+
+        throw new IllegalArgumentException(String.format(
+                "Class %s does not provide a method named '%s'.",
+                clazz.getName(),
+                methodName));
+    }
+
+    protected final Method findMethod(Object subject, String methodName)
+    {
+        return findMethod(subject.getClass(), methodName);
+    }
+
+    protected final Method findMethod(String methodName)
+    {
+        return findMethod(this, methodName);
+    }
 
     protected final Resource newResource()
     {
         return newMock(Resource.class);
     }
 
+    protected final ServiceLocator newServiceLocator()
+    {
+        return newMock(ServiceLocator.class);
+    }
+
+    protected final ContributionDef newContributionDef()
+    {
+        return newMock(ContributionDef.class);
+    }
+
+    @SuppressWarnings("unchecked")
+    protected final <T> OrderedConfiguration<T> newOrderedConfiguration()
+    {
+        return newMock(OrderedConfiguration.class);
+    }
+
     protected final void train_getServiceInterface(ServiceDef def, Class serviceInterface)
     {
         def.getServiceInterface();
@@ -64,7 +115,7 @@
         locator.getService(serviceId, serviceInterface);
         setReturnValue(service);
     }
-
+    
     protected final <T> void train_getService(ServiceLocator locator, Class<T> serviceInterface,
             T service)
     {
@@ -78,6 +129,18 @@
         setReturnValue(service);
     }
 
+    protected final ObjectProvider newObjectProvider()
+    {
+        return newMock(ObjectProvider.class);
+    }
+
+    protected final <T> void train_provide(ObjectProvider provider, String expression,
+            Class<T> objectType, ServiceLocator locator, T object)
+    {
+        provider.provide(expression, objectType, locator);
+        setReturnValue(object);
+    }
+
     protected final ObjectCreator newObjectCreator()
     {
         return newMock(ObjectCreator.class);
@@ -94,6 +157,7 @@
     {
         resources.getServiceId();
         setReturnValue(serviceId).atLeastOnce();
+
     }
 
     protected final void train_createInterceptor(ServiceDecorator decorator, Object coreObject,
@@ -103,6 +167,11 @@
         setReturnValue(interceptor);
     }
 
+    protected final ServiceBuilderResources newServiceCreatorResources()
+    {
+        return newMock(ServiceBuilderResources.class);
+    }
+
     protected final ServiceDecorator newServiceDecorator()
     {
         return newMock(ServiceDecorator.class);
@@ -114,68 +183,18 @@
         setReturnValue(log).atLeastOnce();
     }
 
-    protected final Method findMethod(Class clazz, String methodName)
-    {
-        for (Method method : clazz.getMethods())
-        {
-            if (method.getName().equals(methodName))
-                return method;
-        }
-
-        throw new IllegalArgumentException(String.format(
-                "Class %s does not provide a method named '%s'.",
-                clazz.getName(),
-                methodName));
-    }
-
-    protected final Method findMethod(Object subject, String methodName)
-    {
-        return findMethod(subject.getClass(), methodName);
-    }
-
-    protected final Method findMethod(String methodName)
-    {
-        return findMethod(this, methodName);
-    }
-
-    protected final Configuration newConfiguration()
-    {
-        return newMock(Configuration.class);
-    }
-
-    protected final ServiceLocator newServiceLocator()
-    {
-        return newMock(ServiceLocator.class);
-    }
-
-    @SuppressWarnings("unchecked")
-    protected final <T> OrderedConfiguration<T> newOrderedConfiguration()
-    {
-        return newMock(OrderedConfiguration.class);
-    }
-
-    @SuppressWarnings("unchecked")
-    protected final <K, V> MappedConfiguration<K, V> newMappedConfiguration()
-    {
-        return newMock(MappedConfiguration.class);
-    }
-
-    protected final ContributionDef newContributionDef()
-    {
-        return newMock(ContributionDef.class);
-    }
-
-    protected final ServiceBuilderResources newServiceCreatorResources()
-    {
-        return newMock(ServiceBuilderResources.class);
-    }
-
     protected final void train_getModuleId(ModuleDef def, String moduleId)
     {
         def.getModuleId();
         setReturnValue(moduleId).atLeastOnce();
     }
 
+    /** Frequently used as a placeholder for an arbitrary service (but its nice and simple). */
+    protected final Runnable newRunnable()
+    {
+        return newMock(Runnable.class);
+    }
+
     protected final ModuleDef newModuleDef()
     {
         return newMock(ModuleDef.class);
@@ -193,12 +212,6 @@
         return newMock(DecoratorDef.class);
     }
 
-    /** Frequently used as a placeholder for an arbitrary service (but its nice and simple). */
-    protected final Runnable newRunnable()
-    {
-        return newMock(Runnable.class);
-    }
-
     protected final Location newLocation()
     {
         return newMock(Location.class);
@@ -228,6 +241,18 @@
     protected final TypeCoercer newTypeCoercer()
     {
         return newMock(TypeCoercer.class);
+    }
+
+    @SuppressWarnings("unchecked")
+    protected final <T> Configuration<T> newConfiguration()
+    {
+        return newMock(Configuration.class);
+    }
+
+    @SuppressWarnings("unchecked")
+    protected final <K, V> MappedConfiguration<K, V> newMappedConfiguration()
+    {
+        return newMock(MappedConfiguration.class);
     }
 
 }

Added: tapestry/tapestry5/tapestry-ioc/trunk/src/site/resources/css/jdstyle.css
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/site/resources/css/jdstyle.css?view=auto&rev=477910
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/resources/css/jdstyle.css (added)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/resources/css/jdstyle.css Tue Nov 21 13:48:47 2006
@@ -0,0 +1,117 @@
+/* Javadoc style sheet */
+
+/* Define colors, fonts and other style attributes here to override the defaults  */
+
+/* Page background color */
+body { 	font-family: Arial;
+	background-color: white;
+	font-size: 10pt;
+ }
+td { 	font-family: Arial;
+	font-size: 10pt;
+ }
+/* Table colors */
+.TableHeadingColor     { background: #F4F4F4 }
+.TableSubHeadingColor  { background: #F4F4F4 }
+.TableRowColor         { background: #FFFFFF }
+
+/* Font used in left-hand frame lists */
+.FrameTitleFont   { font-size: normal; font-family: Arial }
+.FrameHeadingFont { font-size: normal; font-family: Arial }
+.FrameItemFont    { font-size: normal; font-family: Arial }
+
+/* Example of smaller, sans-serif font in frames */
+/* .FrameItemFont  { font-size: 10pt; font-family: Helvetica, Arial, sans-serif } */
+
+/* Navigation bar fonts and colors */
+.NavBarCell1    { background-color:#F4F4F4;}
+.NavBarCell1Rev { background-color:silver;}
+
+.NavBarFont1    { font-family: Arial, Helvetica, sans-serif; color:#000000;}
+.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;}
+
+.NavBarCell2    { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;}
+.NavBarCell3    { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;}
+
+A {
+    color: #003399;
+}
+
+A:active {
+    color: #003399;
+}
+
+A:visited {
+    color: #888888;
+}
+
+P, OL, UL, LI, DL, DT, DD, BLOCKQUOTE {
+    color: #000000;
+}
+
+TD, TH, SPAN {
+    color: #000000;
+}
+
+BLOCKQUOTE {
+    margin-right: 0px;
+}
+
+
+/*H1, H2, H3, H4, H5, H6    {
+    color: #000000;
+    font-weight:500;
+    margin-top:10px;
+    padding-top:15px;
+}
+
+H1 { font-size: 150%; }
+H2 { font-size: 140%; }
+H3 { font-size: 110%; font-weight: bold; }
+H4 { font-size: 110%; font-weight: bold;}
+H5 { font-size: 100%; font-style: italic; }
+H6 { font-size: 100%; font-style: italic; }*/
+
+TT {
+font-size: 90%;
+    font-family: "Courier New", Courier, monospace;
+    color: #000000;
+}
+
+PRE {
+font-size: 90%;
+    padding: 5px;
+    border-style: solid;
+    border-width: 1px;
+    border-color: #CCCCCC;
+    background-color: #F4F4F4;
+}
+
+UL, OL, LI {
+    list-style: disc;
+}
+
+HR  {
+    width: 100%;
+    height: 1px;
+    background-color: #CCCCCC;
+    border-width: 0px;
+    padding: 0px;
+    color: #CCCCCC;
+}
+
+.variablelist { 
+    padding-top: 10; 
+    padding-bottom:10; 
+    margin:0;
+}
+
+.itemizedlist, UL { 
+    padding-top: 0; 
+    padding-bottom:0; 
+    margin:0; 
+}
+
+.term { 
+    font-weight:bold;
+}

Added: tapestry/tapestry5/tapestry-ioc/trunk/src/site/resources/css/site.css
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/site/resources/css/site.css?view=auto&rev=477910
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/resources/css/site.css (added)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/resources/css/site.css Tue Nov 21 13:48:47 2006
@@ -0,0 +1,40 @@
+a.externalLink, a.externalLink:link, a.externalLink:visited, a.externalLink:active, a.externalLink:hover {
+  background: none;
+  padding-right: 0;
+}
+
+body ul {
+  list-style-type: square;
+}
+
+#downloadbox {
+  float: right;
+  margin: 0 1em 2em 2em;
+  padding: 1em;
+  border: 1px solid #999;
+  background-color: #eee;
+}
+
+#downloadbox h5 {
+  color: #000;
+  margin: 0;
+  border-bottom: 1px solid #aaaaaa;
+  font-size: smaller;
+  padding: 0;
+}
+
+#downloadbox p {
+  margin-top: 1em;
+  margin-bottom: 0;
+}
+
+#downloadbox ul {
+  margin-top: 0;
+  margin-bottom: 1em;
+  list-style-type: disc;
+}
+
+#downloadbox li {
+  font-size: smaller;
+}
+

Added: tapestry/tapestry5/tapestry-ioc/trunk/src/site/resources/images/asf_logo_wide.gif
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/site/resources/images/asf_logo_wide.gif?view=auto&rev=477910
==============================================================================
Binary file - no diff available.

Propchange: tapestry/tapestry5/tapestry-ioc/trunk/src/site/resources/images/asf_logo_wide.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: tapestry/tapestry5/tapestry-ioc/trunk/src/test/conf/testng.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/conf/testng.xml?view=auto&rev=477910
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/conf/testng.xml (added)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/conf/testng.xml Tue Nov 21 13:48:47 2006
@@ -0,0 +1,29 @@
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
+<!-- 
+   Copyright 2006 The Apache Software Foundation
+
+   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.
+-->
+
+<suite name="Tapestry IOC" parallel="false" thread-count="10" annotations="1.5" verbose="2">
+  <test name="Tapestry IOC">
+    <packages>
+      <package name="org.apache.tapestry.ioc"/>
+      <package name="org.apache.tapestry.ioc.services"/>
+      <package name="org.apache.tapestry.ioc.util"/>
+      <package name="org.apache.tapestry.ioc.internal"/>
+      <package name="org.apache.tapestry.ioc.internal.services"/>
+      <package name="org.apache.tapestry.ioc.internal.util"/>
+    </packages>
+  </test>
+</suite>

Copied: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/BaseLocatableTest.java (from r477721, tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/BaseLocatableTest.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/BaseLocatableTest.java?view=diff&rev=477910&p1=tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/BaseLocatableTest.java&r1=477721&p2=tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/BaseLocatableTest.java&r2=477910
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/BaseLocatableTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/BaseLocatableTest.java Tue Nov 21 13:48:47 2006
@@ -12,47 +12,41 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry;
-
-import org.apache.tapestry.ioc.BaseLocatable;
-import org.apache.tapestry.ioc.Locatable;
-import org.apache.tapestry.ioc.Location;
-import org.apache.tapestry.test.TapestryTestCase;
-import org.testng.annotations.Test;
-
-/**
- * 
- */
-public class BaseLocatableTest extends TapestryTestCase
-{
-
-    static class LocatableFixture extends BaseLocatable
-    {
-        LocatableFixture(Location location)
-        {
-            super(location);
-        }
-    }
-
-    @Test
-    public void location_property_is_readable()
-    {
-        Location location = newMock(Location.class);
-
-        replay();
-
-        Locatable locatable = new LocatableFixture(location);
-
-        verify();
-
-        assertSame(locatable.getLocation(), location);
-    }
-
-    @Test
-    public void null_is_allowed_for_location()
-    {
-        Locatable locatable = new LocatableFixture(null);
-
-        assertNull(locatable.getLocation());
-    }
-}
+package org.apache.tapestry.ioc;
+
+import org.apache.tapestry.ioc.test.IOCTestCase;
+import org.testng.annotations.Test;
+
+public class BaseLocatableTest extends IOCTestCase
+{
+
+    static class LocatableFixture extends BaseLocatable
+    {
+        LocatableFixture(Location location)
+        {
+            super(location);
+        }
+    }
+
+    @Test
+    public void location_property_is_readable()
+    {
+        Location location = newMock(Location.class);
+
+        replay();
+
+        Locatable locatable = new LocatableFixture(location);
+
+        verify();
+
+        assertSame(locatable.getLocation(), location);
+    }
+
+    @Test
+    public void null_is_allowed_for_location()
+    {
+        Locatable locatable = new LocatableFixture(null);
+
+        assertNull(locatable.getLocation());
+    }
+}

Copied: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/IOCUtilitiesTest.java (from r477721, tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/IOCUtilitiesTest.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/IOCUtilitiesTest.java?view=diff&rev=477910&p1=tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/IOCUtilitiesTest.java&r1=477721&p2=tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/IOCUtilitiesTest.java&r2=477910
==============================================================================
    (empty)

Propchange: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/IOCUtilitiesTest.java
------------------------------------------------------------------------------
    cvs2svn:cvs-rev = 1.3

Propchange: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/IOCUtilitiesTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/IOCUtilitiesTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java (from r477721, tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java?view=diff&rev=477910&p1=tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java&r1=477721&p2=tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java&r2=477910
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java Tue Nov 21 13:48:47 2006
@@ -12,360 +12,358 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.ioc;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.tapestry.internal.test.InternalBaseTestCase;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-/**
- * A few tests that are easiest (or even just possible) by building a Registry and trying out a few
- * things.
- * 
- * 
- */
-public class IntegrationTest extends InternalBaseTestCase
-{
-    private Registry buildRegistry()
-    {
-        return buildRegistry(FredModule.class, BarneyModule.class);
-    }
-
-    @Test
-    public void static_builder_method_does_not_instantiate_builder()
-    {
-        StaticModule.setInstantiated(false);
-        StaticModule.setFredRan(false);
-
-        Registry r = buildRegistry(StaticModule.class);
-
-        Runnable fred = r.getService("static.Fred", Runnable.class);
-
-        fred.run();
-
-        assertFalse(StaticModule.isInstantiated());
-        assertTrue(StaticModule.getFredRan());
-    }
-
-    @Test
-    public void static_decorator_method_does_not_instantiate_builder()
-    {
-        StaticModule.setInstantiated(false);
-        StaticModule.setDecoratorRan(false);
-
-        Registry r = buildRegistry(StaticModule.class);
-
-        Runnable fred = r.getService("static.Barney", Runnable.class);
-
-        fred.run();
-
-        assertFalse(StaticModule.isInstantiated());
-        assertTrue(StaticModule.getDecoratorRan());
-    }
-
-    @Test
-    public void static_contributor_method_does_not_instantiate_builder()
-    {
-        StaticModule.setInstantiated(false);
-
-        Registry r = buildRegistry(StaticModule.class);
-
-        NameListHolder holder = r.getService("static.Names", NameListHolder.class);
-
-        List<String> names = holder.getNames();
-
-        assertEquals(names, Arrays.asList("Fred"));
-
-        assertFalse(StaticModule.isInstantiated());
-    }
-
-    @Test
-    public void shutdown_deactivates_proxies()
-    {
-        Registry r = buildRegistry();
-
-        Runnable service = r.getService("fred.Fred", Runnable.class);
-
-        service.run();
-
-        r.shutdown();
-
-        try
-        {
-            service.run();
-            unreachable();
-        }
-        catch (IllegalStateException ex)
-        {
-            assertEquals(
-                    ex.getMessage(),
-                    "Proxy for service fred.Fred is no longer active because the IOC Registry has been shut down.");
-        }
-
-        // Show that toString() still works, even for a shutdown proxy.
-
-        assertEquals(service.toString(), "<Proxy for fred.Fred(java.lang.Runnable)>");
-    }
-
-    /**
-     * Along the way, we also test a few other things, such as decorator matching and automatic
-     * dependency resolution.
-     */
-    @Test
-    public void public_service_decorator_order()
-    {
-        Registry r = buildRegistry();
-
-        Runnable service = r.getService("fred.Fred", Runnable.class);
-
-        // Force creation
-
-        service.run();
-
-        List<String> names = r.getService(DecoratorList.class).getNames();
-
-        // Note that the order of invocation appears backwards, since we build back-to-front
-
-        assertEquals(names, Arrays.asList("gamma", "beta", "alpha"));
-    }
-
-    /**
-     * Along the way, we are demonstrating that decorators can target multiple services within a
-     * module, and can target services in other modules. The main point, though, is the difference
-     * between a private and a public service in terms of decoration.
-     */
-    @Test
-    public void private_service_decorator_order()
-    {
-        Registry r = buildRegistry();
-
-        Runnable service = r.getService("fred.PrivateFredAlias", Runnable.class);
-
-        // Force creation
-
-        service.run();
-
-        List<String> names = r.getService(DecoratorList.class).getNames();
-
-        // The trick here is that the public service (PrivateFredAlias) was decorated first with the
-        // full set (the same as the previous test), then the private service (PrivateFred) was
-        // decorated just with decorators from module fred.
-
-        assertEquals(names, Arrays.asList("gamma", "beta", "alpha", "beta", "alpha"));
-    }
-
-    @Test
-    public void public_service_unordered_configuration()
-    {
-        Registry r = buildRegistry();
-
-        NameListHolder service = r.getService("fred.UnorderedNames", NameListHolder.class);
-
-        List<String> names = service.getNames();
-
-        assertEquals(names, Arrays.asList("Beta", "Gamma", "UnorderedNames"));
-    }
-
-    /**
-     * We don't have to do as many public/private etc. tests for the other types of configuration,
-     * because the code paths are so similar.
-     */
-
-    @Test
-    public void service_ordered_configuration()
-    {
-        Registry r = buildRegistry();
-
-        NameListHolder service = r.getService("fred.OrderedNames", NameListHolder.class);
-
-        List<String> names = service.getNames();
-
-        assertEquals(names, Arrays.asList("BARNEY", "FRED"));
-
-    }
-
-    @SuppressWarnings("unchecked")
-    @Test
-    public void service_mapped_configuration()
-    {
-        Registry r = buildRegistry();
-
-        Sizer sizer = r.getService("barney.Sizer", Sizer.class);
-
-        assertEquals(sizer.size(null), 0);
-
-        // Have to be exact on type here.
-
-        List list = new ArrayList();
-        list.add(1);
-        list.add(2);
-        list.add(3);
-
-        assertEquals(sizer.size(list), 3);
-
-        Map map = new HashMap();
-        map.put("fred", "flinstone");
-        map.put("barney", "rubble");
-
-        assertEquals(sizer.size(map), 2);
-
-        // Random objects are size 1
-
-        assertEquals(sizer.size(this), 1);
-    }
-
-    @Test
-    public void private_service_unordered_configuration()
-    {
-        Registry r = buildRegistry();
-
-        NameListHolder service = r.getService(
-                "fred.PrivateUnorderedNamesAlias",
-                NameListHolder.class);
-
-        List<String> names = service.getNames();
-
-        assertEquals(names, Arrays.asList("Omega", "PrivateUnorderedNames"));
-    }
-
-    @Test
-    public void unknown_lifecycle()
-    {
-        Registry r = buildRegistry(UnknownLifecycleModule.class);
-
-        try
-        {
-            r.getService("ioc.test.UnknownLifecycle", Runnable.class);
-            unreachable();
-        }
-        catch (Exception ex)
-        {
-            assertEquals(
-                    ex.getMessage(),
-                    "Error building service proxy for service 'ioc.test.UnknownLifecycle' "
-                            + "(at org.apache.tapestry.ioc.UnknownLifecycleModule.buildUnknownLifecycle()): "
-                            + "Unknown service lifecycle 'magic'.");
-        }
-    }
-
-    @Test
-    public void simple_perthread() throws Exception
-    {
-        final Registry r = buildRegistry(PerThreadModule.class);
-
-        final StringHolder holder = r.getService(StringHolder.class);
-
-        // Something about some of the other tests causes this one to fail
-        // unless we start with cleanupThread(), there must be a loose ThreadLocal
-        // hanging around causing problems.
-
-        r.cleanupThread();
-
-        holder.setValue("fred");
-        assertEquals(holder.getValue(), "fred", holder.toString());
-
-        Runnable runnable = new Runnable()
-        {
-            public void run()
-            {
-                Assert.assertNull(holder.getValue());
-
-                holder.setValue("barney");
-                assertEquals(holder.getValue(), "barney");
-
-                r.cleanupThread();
-            }
-        };
-
-        Thread t = new Thread(runnable);
-
-        t.start();
-        t.join();
-
-        assertEquals(holder.getValue(), "fred");
-
-        r.cleanupThread();
-    }
-
-    /**
-     * This test fails at times and I'm not sure why. It's some kind of interaction with other tests
-     * but hard to figure out. Damn ThreadLocals!
-     */
-    @Test
-    public void registry_thread_cleanup()
-    {
-        Registry r = buildRegistry(PerThreadModule.class);
-
-        r.cleanupThread();
-
-        StringHolder holder = r.getService(StringHolder.class);
-
-        assertNull(holder.getValue());
-
-        holder.setValue("fred");
-        assertEquals(holder.getValue(), "fred");
-
-        r.cleanupThread();
-
-        assertNull(holder.getValue());
-    }
-
-    @Test
-    public void use_of_service_object_provider_prefix()
-    {
-        Registry r = buildRegistry(ServiceObjectProviderModule.class);
-
-        StringTransformer st = r.getObject(
-                "service:ioc.test.PublicTransformer",
-                StringTransformer.class);
-
-        // The PublicTransform gets the PrivateTransformer via
-        // an @Inject.
-
-        assertEquals(st.transform("fred"), "FRED");
-    }
-
-    @Test
-    public void recursive_module_construction_is_caught()
-    {
-        Registry r = buildRegistry(RecursiveConstructorModule.class);
-
-        try
-        {
-            Runnable runnable = r.getService("recursive.Runnable", Runnable.class);
-
-            // We can get the proxy, but invoking a method causes
-            // the module to be instantiated ... but that also invokes a method on
-            // the proxy.
-
-            runnable.run();
-
-            unreachable();
-        }
-        catch (RuntimeException ex)
-        {
-            assertTrue(ex.getMessage().contains("has failed due to recursion"));
-        }
-    }
-
-    @Test
-    public void eager_service_loading()
-    {
-        assertFalse(EagerLoadModule._eagerLoadDidHappen);
-
-        Registry r = buildRegistry(EagerLoadModule.class);
-
-        // Prevents warning: r is never read
-        assertNotNull(r);
-        
-        assertTrue(EagerLoadModule._eagerLoadDidHappen);
-
-        r = null;
-    }
-}
+package org.apache.tapestry.ioc;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tapestry.ioc.internal.IOCInternalTestCase;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * A few tests that are easiest (or even just possible) by building a Registry and trying out a few
+ * things.
+ */
+public class IntegrationTest extends IOCInternalTestCase
+{
+    private Registry buildRegistry()
+    {
+        return buildRegistry(FredModule.class, BarneyModule.class);
+    }
+
+    @Test
+    public void static_builder_method_does_not_instantiate_builder()
+    {
+        StaticModule.setInstantiated(false);
+        StaticModule.setFredRan(false);
+
+        Registry r = buildRegistry(StaticModule.class);
+
+        Runnable fred = r.getService("static.Fred", Runnable.class);
+
+        fred.run();
+
+        assertFalse(StaticModule.isInstantiated());
+        assertTrue(StaticModule.getFredRan());
+    }
+
+    @Test
+    public void static_decorator_method_does_not_instantiate_builder()
+    {
+        StaticModule.setInstantiated(false);
+        StaticModule.setDecoratorRan(false);
+
+        Registry r = buildRegistry(StaticModule.class);
+
+        Runnable fred = r.getService("static.Barney", Runnable.class);
+
+        fred.run();
+
+        assertFalse(StaticModule.isInstantiated());
+        assertTrue(StaticModule.getDecoratorRan());
+    }
+
+    @Test
+    public void static_contributor_method_does_not_instantiate_builder()
+    {
+        StaticModule.setInstantiated(false);
+
+        Registry r = buildRegistry(StaticModule.class);
+
+        NameListHolder holder = r.getService("static.Names", NameListHolder.class);
+
+        List<String> names = holder.getNames();
+
+        assertEquals(names, Arrays.asList("Fred"));
+
+        assertFalse(StaticModule.isInstantiated());
+    }
+
+    @Test
+    public void shutdown_deactivates_proxies()
+    {
+        Registry r = buildRegistry();
+
+        Runnable service = r.getService("fred.Fred", Runnable.class);
+
+        service.run();
+
+        r.shutdown();
+
+        try
+        {
+            service.run();
+            unreachable();
+        }
+        catch (IllegalStateException ex)
+        {
+            assertEquals(
+                    ex.getMessage(),
+                    "Proxy for service fred.Fred is no longer active because the IOC Registry has been shut down.");
+        }
+
+        // Show that toString() still works, even for a shutdown proxy.
+
+        assertEquals(service.toString(), "<Proxy for fred.Fred(java.lang.Runnable)>");
+    }
+
+    /**
+     * Along the way, we also test a few other things, such as decorator matching and automatic
+     * dependency resolution.
+     */
+    @Test
+    public void public_service_decorator_order()
+    {
+        Registry r = buildRegistry();
+
+        Runnable service = r.getService("fred.Fred", Runnable.class);
+
+        // Force creation
+
+        service.run();
+
+        List<String> names = r.getService(DecoratorList.class).getNames();
+
+        // Note that the order of invocation appears backwards, since we build back-to-front
+
+        assertEquals(names, Arrays.asList("gamma", "beta", "alpha"));
+    }
+
+    /**
+     * Along the way, we are demonstrating that decorators can target multiple services within a
+     * module, and can target services in other modules. The main point, though, is the difference
+     * between a private and a public service in terms of decoration.
+     */
+    @Test
+    public void private_service_decorator_order()
+    {
+        Registry r = buildRegistry();
+
+        Runnable service = r.getService("fred.PrivateFredAlias", Runnable.class);
+
+        // Force creation
+
+        service.run();
+
+        List<String> names = r.getService(DecoratorList.class).getNames();
+
+        // The trick here is that the public service (PrivateFredAlias) was decorated first with the
+        // full set (the same as the previous test), then the private service (PrivateFred) was
+        // decorated just with decorators from module fred.
+
+        assertEquals(names, Arrays.asList("gamma", "beta", "alpha", "beta", "alpha"));
+    }
+
+    @Test
+    public void public_service_unordered_configuration()
+    {
+        Registry r = buildRegistry();
+
+        NameListHolder service = r.getService("fred.UnorderedNames", NameListHolder.class);
+
+        List<String> names = service.getNames();
+
+        assertEquals(names, Arrays.asList("Beta", "Gamma", "UnorderedNames"));
+    }
+
+    /**
+     * We don't have to do as many public/private etc. tests for the other types of configuration,
+     * because the code paths are so similar.
+     */
+
+    @Test
+    public void service_ordered_configuration()
+    {
+        Registry r = buildRegistry();
+
+        NameListHolder service = r.getService("fred.OrderedNames", NameListHolder.class);
+
+        List<String> names = service.getNames();
+
+        assertEquals(names, Arrays.asList("BARNEY", "FRED"));
+
+    }
+
+    @SuppressWarnings("unchecked")
+    @Test
+    public void service_mapped_configuration()
+    {
+        Registry r = buildRegistry();
+
+        Sizer sizer = r.getService("barney.Sizer", Sizer.class);
+
+        assertEquals(sizer.size(null), 0);
+
+        // Have to be exact on type here.
+
+        List list = new ArrayList();
+        list.add(1);
+        list.add(2);
+        list.add(3);
+
+        assertEquals(sizer.size(list), 3);
+
+        Map map = new HashMap();
+        map.put("fred", "flinstone");
+        map.put("barney", "rubble");
+
+        assertEquals(sizer.size(map), 2);
+
+        // Random objects are size 1
+
+        assertEquals(sizer.size(this), 1);
+    }
+
+    @Test
+    public void private_service_unordered_configuration()
+    {
+        Registry r = buildRegistry();
+
+        NameListHolder service = r.getService(
+                "fred.PrivateUnorderedNamesAlias",
+                NameListHolder.class);
+
+        List<String> names = service.getNames();
+
+        assertEquals(names, Arrays.asList("Omega", "PrivateUnorderedNames"));
+    }
+
+    @Test
+    public void unknown_lifecycle()
+    {
+        Registry r = buildRegistry(UnknownLifecycleModule.class);
+
+        try
+        {
+            r.getService("ioc.test.UnknownLifecycle", Runnable.class);
+            unreachable();
+        }
+        catch (Exception ex)
+        {
+            assertEquals(
+                    ex.getMessage(),
+                    "Error building service proxy for service 'ioc.test.UnknownLifecycle' "
+                            + "(at org.apache.tapestry.ioc.UnknownLifecycleModule.buildUnknownLifecycle()): "
+                            + "Unknown service lifecycle 'magic'.");
+        }
+    }
+
+    @Test
+    public void simple_perthread() throws Exception
+    {
+        final Registry r = buildRegistry(PerThreadModule.class);
+
+        final StringHolder holder = r.getService(StringHolder.class);
+
+        // Something about some of the other tests causes this one to fail
+        // unless we start with cleanupThread(), there must be a loose ThreadLocal
+        // hanging around causing problems.
+
+        r.cleanupThread();
+
+        holder.setValue("fred");
+        assertEquals(holder.getValue(), "fred", holder.toString());
+
+        Runnable runnable = new Runnable()
+        {
+            public void run()
+            {
+                Assert.assertNull(holder.getValue());
+
+                holder.setValue("barney");
+                assertEquals(holder.getValue(), "barney");
+
+                r.cleanupThread();
+            }
+        };
+
+        Thread t = new Thread(runnable);
+
+        t.start();
+        t.join();
+
+        assertEquals(holder.getValue(), "fred");
+
+        r.cleanupThread();
+    }
+
+    /**
+     * This test fails at times and I'm not sure why. It's some kind of interaction with other tests
+     * but hard to figure out. Damn ThreadLocals!
+     */
+    @Test
+    public void registry_thread_cleanup()
+    {
+        Registry r = buildRegistry(PerThreadModule.class);
+
+        r.cleanupThread();
+
+        StringHolder holder = r.getService(StringHolder.class);
+
+        assertNull(holder.getValue());
+
+        holder.setValue("fred");
+        assertEquals(holder.getValue(), "fred");
+
+        r.cleanupThread();
+
+        assertNull(holder.getValue());
+    }
+
+    @Test
+    public void use_of_service_object_provider_prefix()
+    {
+        Registry r = buildRegistry(ServiceObjectProviderModule.class);
+
+        StringTransformer st = r.getObject(
+                "service:ioc.test.PublicTransformer",
+                StringTransformer.class);
+
+        // The PublicTransform gets the PrivateTransformer via
+        // an @Inject.
+
+        assertEquals(st.transform("fred"), "FRED");
+    }
+
+    @Test
+    public void recursive_module_construction_is_caught()
+    {
+        Registry r = buildRegistry(RecursiveConstructorModule.class);
+
+        try
+        {
+            Runnable runnable = r.getService("recursive.Runnable", Runnable.class);
+
+            // We can get the proxy, but invoking a method causes
+            // the module to be instantiated ... but that also invokes a method on
+            // the proxy.
+
+            runnable.run();
+
+            unreachable();
+        }
+        catch (RuntimeException ex)
+        {
+            assertTrue(ex.getMessage().contains("has failed due to recursion"));
+        }
+    }
+
+    @Test
+    public void eager_service_loading()
+    {
+        assertFalse(EagerLoadModule._eagerLoadDidHappen);
+
+        Registry r = buildRegistry(EagerLoadModule.class);
+
+        // Prevents warning: r is never read
+        assertNotNull(r);
+
+        assertTrue(EagerLoadModule._eagerLoadDidHappen);
+
+        r = null;
+    }
+}

Copied: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/RegistryBuilderTest.java (from r477721, tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/RegistryBuilderTest.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/RegistryBuilderTest.java?view=diff&rev=477910&p1=tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/RegistryBuilderTest.java&r1=477721&p2=tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/RegistryBuilderTest.java&r2=477910
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/RegistryBuilderTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/RegistryBuilderTest.java Tue Nov 21 13:48:47 2006
@@ -12,66 +12,63 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.ioc;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.jar.Manifest;
-
-import org.apache.tapestry.internal.test.InternalBaseTestCase;
-import org.testng.annotations.Test;
-
-/**
- * 
- */
-public class RegistryBuilderTest extends InternalBaseTestCase
-{
-    @Test
-    public void sub_module()
-    {
-        RegistryBuilder builder = new RegistryBuilder();
-
-        builder.add(MasterModule.class);
-
-        Registry r = builder.build();
-
-        // Borrowed from IntegrationTest, this will only work if both FredModule and BarneyModule
-        // are loaded.
-
-        NameListHolder service = r.getService("fred.UnorderedNames", NameListHolder.class);
-
-        List<String> names = service.getNames();
-
-        assertEquals(names, Arrays.asList("Beta", "Gamma", "UnorderedNames"));
-    }
-
-    @Test
-    public void manifest()
-    {
-        RegistryBuilder builder = new RegistryBuilder();
-
-        String value = String.format("%s, %s, %s", FredModule.class.getName(), BarneyModule.class
-                .getName(), RegistryBuilderTestModule.class.getName());
-
-        Manifest mf = new Manifest();
-
-        mf.getMainAttributes().putValue(IOCConstants.MODULE_BUILDER_MANIFEST_ENTRY_NAME, value);
-
-        // A package private method. Add in the two modules as if they were listed in the manifest.
-
-        IOCUtilities.addModulesInManifest(builder, mf);
-
-        Registry registry = builder.build();
-
-        Square service = registry.getService(Square.class);
-
-        assertEquals(service.square(4), 16l);
-
-        // This proves that the IOC works, the service builder method was invoked, that the
-        // ClassFactory service was accessed and used.
-
-        assertEquals(
-                service.toString(),
-                "<Proxy for ioc.test.Square(org.apache.tapestry.ioc.Square)>");
-    }
-}
+package org.apache.tapestry.ioc;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.jar.Manifest;
+
+import org.apache.tapestry.ioc.test.IOCTestCase;
+import org.testng.annotations.Test;
+
+public class RegistryBuilderTest extends IOCTestCase
+{
+    @Test
+    public void sub_module()
+    {
+        RegistryBuilder builder = new RegistryBuilder();
+
+        builder.add(MasterModule.class);
+
+        Registry r = builder.build();
+
+        // Borrowed from IntegrationTest, this will only work if both FredModule and BarneyModule
+        // are loaded.
+
+        NameListHolder service = r.getService("fred.UnorderedNames", NameListHolder.class);
+
+        List<String> names = service.getNames();
+
+        assertEquals(names, Arrays.asList("Beta", "Gamma", "UnorderedNames"));
+    }
+
+    @Test
+    public void manifest()
+    {
+        RegistryBuilder builder = new RegistryBuilder();
+
+        String value = String.format("%s, %s, %s", FredModule.class.getName(), BarneyModule.class
+                .getName(), RegistryBuilderTestModule.class.getName());
+
+        Manifest mf = new Manifest();
+
+        mf.getMainAttributes().putValue(IOCConstants.MODULE_BUILDER_MANIFEST_ENTRY_NAME, value);
+
+        // A package private method. Add in the two modules as if they were listed in the manifest.
+
+        IOCUtilities.addModulesInManifest(builder, mf);
+
+        Registry registry = builder.build();
+
+        Square service = registry.getService(Square.class);
+
+        assertEquals(service.square(4), 16l);
+
+        // This proves that the IOC works, the service builder method was invoked, that the
+        // ClassFactory service was accessed and used.
+
+        assertEquals(
+                service.toString(),
+                "<Proxy for ioc.test.Square(org.apache.tapestry.ioc.Square)>");
+    }
+}

Copied: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ContributionDefImplTest.java (from r477721, tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/internal/ContributionDefImplTest.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ContributionDefImplTest.java?view=diff&rev=477910&p1=tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/internal/ContributionDefImplTest.java&r1=477721&p2=tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ContributionDefImplTest.java&r2=477910
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/internal/ContributionDefImplTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ContributionDefImplTest.java Tue Nov 21 13:48:47 2006
@@ -12,187 +12,183 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.ioc.internal;
-
-import java.lang.reflect.Method;
-
-import org.apache.tapestry.internal.test.InternalBaseTestCase;
-import org.apache.tapestry.ioc.Configuration;
-import org.apache.tapestry.ioc.MappedConfiguration;
-import org.apache.tapestry.ioc.ModuleBuilderSource;
-import org.apache.tapestry.ioc.OrderedConfiguration;
-import org.apache.tapestry.ioc.ServiceLocator;
-import org.apache.tapestry.ioc.annotations.InjectService;
-import org.apache.tapestry.ioc.def.ContributionDef;
-import org.apache.tapestry.ioc.internal.ContributionDefImpl;
-import org.testng.annotations.Test;
-
-/**
- * 
- */
-public class ContributionDefImplTest extends InternalBaseTestCase implements ModuleBuilderSource
-{
-    private Object _toContribute;
-
-    public Object getModuleBuilder()
-    {
-        return this;
-    }
-
-    @SuppressWarnings("unchecked")
-    @Test
-    public void unordered_contribution()
-    {
-        _toContribute = new Object();
-        Configuration configuration = newConfiguration();
-        ServiceLocator locator = newServiceLocator();
-
-        configuration.add(_toContribute);
-
-        replay();
-
-        Method m = findMethod("contributeUnordered");
-        ContributionDef def = new ContributionDefImpl("foo.Bar", m);
-
-        def.contribute(this, locator, configuration);
-
-        verify();
-    }
-
-    @SuppressWarnings("unchecked")
-    @Test
-    public void unordered_collection_with_service_lookup()
-    {
-        Configuration configuration = newConfiguration();
-        ServiceLocator locator = newServiceLocator();
-        UpcaseService service = newUpcaseService();
-
-        train_getService(locator, "zip.Zap", UpcaseService.class, service);
-
-        configuration.add(service);
-
-        replay();
-
-        Method m = findMethod("contributeUnorderedParameter");
-        ContributionDef def = new ContributionDefImpl("foo.Bar", m);
-
-        def.contribute(this, locator, configuration);
-
-        verify();
-    }
-
-    @Test
-    public void unordered_collection_with_incorrect_configuration_parameter()
-    {
-        Configuration configuration = newConfiguration();
-        ServiceLocator locator = newServiceLocator();
-
-        Throwable t = new RuntimeException("Missing service.");
-
-        locator.getService(MappedConfiguration.class);
-        setThrowable(t);
-
-        replay();
-
-        Method m = findMethod("contributeUnorderedWrongParameter");
-        ContributionDef def = new ContributionDefImpl("foo.Bar", m);
-
-        try
-        {
-            def.contribute(this, locator, configuration);
-            unreachable();
-        }
-        catch (RuntimeException ex)
-        {
-            assertEquals(ex.getMessage(), "Error invoking service contribution method "
-                    + getClass().getName()
-                    + ".contributeUnorderedWrongParameter(MappedConfiguration): Missing service.");
-        }
-
-        verify();
-    }
-
-    // From here on in, it's an almost identical code path, so we won't be
-    // as exhaustive.
-
-    @SuppressWarnings("unchecked")
-    @Test
-    public void ordered_collection_with_service_lookup()
-    {
-        OrderedConfiguration configuration = newOrderedConfiguration();
-        ServiceLocator locator = newServiceLocator();
-        UpcaseService service = newUpcaseService();
-
-        train_getService(locator, "zip.Zap", UpcaseService.class, service);
-
-        configuration.add("fred", service);
-
-        replay();
-
-        Method m = findMethod("contributeOrderedParameter");
-        ContributionDef def = new ContributionDefImpl("foo.Bar", m);
-
-        def.contribute(this, locator, configuration);
-
-        verify();
-    }
-
-    @SuppressWarnings("unchecked")
-    @Test
-    public void mapped_collection_with_service_lookup()
-    {
-        MappedConfiguration configuration = newMappedConfiguration();
-        ServiceLocator locator = newServiceLocator();
-        UpcaseService service = newUpcaseService();
-
-        train_getService(locator, "zip.Zap", UpcaseService.class, service);
-
-        configuration.add("upcase", service);
-
-        replay();
-
-        Method m = findMethod("contributeMappedParameter");
-        ContributionDef def = new ContributionDefImpl("foo.Bar", m);
-
-        def.contribute(this, locator, configuration);
-
-        verify();
-    }
-
-    private UpcaseService newUpcaseService()
-    {
-        return newMock(UpcaseService.class);
-    }
-
-    @SuppressWarnings("unchecked")
-    public void contributeUnordered(Configuration configuration)
-    {
-        configuration.add(_toContribute);
-    }
-
-    public void contributeUnorderedParameter(Configuration<UpcaseService> configuration,
-            @InjectService("zip.Zap")
-            UpcaseService service)
-    {
-        configuration.add(service);
-    }
-
-    public void contributeOrderedParameter(OrderedConfiguration<UpcaseService> configuration,
-            @InjectService("zip.Zap")
-            UpcaseService service)
-    {
-        configuration.add("fred", service);
-    }
-
-    public void contributeMappedParameter(MappedConfiguration<String, UpcaseService> configuration,
-            @InjectService("zip.Zap")
-            UpcaseService service)
-    {
-        configuration.add("upcase", service);
-    }
-
-    public void contributeUnorderedWrongParameter(MappedConfiguration configuration)
-    {
-        unreachable();
-    }
-}
+package org.apache.tapestry.ioc.internal;
+
+import java.lang.reflect.Method;
+
+import org.apache.tapestry.ioc.Configuration;
+import org.apache.tapestry.ioc.MappedConfiguration;
+import org.apache.tapestry.ioc.ModuleBuilderSource;
+import org.apache.tapestry.ioc.OrderedConfiguration;
+import org.apache.tapestry.ioc.ServiceLocator;
+import org.apache.tapestry.ioc.annotations.InjectService;
+import org.apache.tapestry.ioc.def.ContributionDef;
+import org.apache.tapestry.ioc.test.IOCTestCase;
+import org.testng.annotations.Test;
+
+public class ContributionDefImplTest extends IOCTestCase implements ModuleBuilderSource
+{
+    private Object _toContribute;
+
+    public Object getModuleBuilder()
+    {
+        return this;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Test
+    public void unordered_contribution()
+    {
+        _toContribute = new Object();
+        Configuration configuration = newConfiguration();
+        ServiceLocator locator = newServiceLocator();
+
+        configuration.add(_toContribute);
+
+        replay();
+
+        Method m = findMethod("contributeUnordered");
+        ContributionDef def = new ContributionDefImpl("foo.Bar", m);
+
+        def.contribute(this, locator, configuration);
+
+        verify();
+    }
+
+    @SuppressWarnings("unchecked")
+    @Test
+    public void unordered_collection_with_service_lookup()
+    {
+        Configuration configuration = newConfiguration();
+        ServiceLocator locator = newServiceLocator();
+        UpcaseService service = newUpcaseService();
+
+        train_getService(locator, "zip.Zap", UpcaseService.class, service);
+
+        configuration.add(service);
+
+        replay();
+
+        Method m = findMethod("contributeUnorderedParameter");
+        ContributionDef def = new ContributionDefImpl("foo.Bar", m);
+
+        def.contribute(this, locator, configuration);
+
+        verify();
+    }
+
+    @Test
+    public void unordered_collection_with_incorrect_configuration_parameter()
+    {
+        Configuration configuration = newConfiguration();
+        ServiceLocator locator = newServiceLocator();
+
+        Throwable t = new RuntimeException("Missing service.");
+
+        locator.getService(MappedConfiguration.class);
+        setThrowable(t);
+
+        replay();
+
+        Method m = findMethod("contributeUnorderedWrongParameter");
+        ContributionDef def = new ContributionDefImpl("foo.Bar", m);
+
+        try
+        {
+            def.contribute(this, locator, configuration);
+            unreachable();
+        }
+        catch (RuntimeException ex)
+        {
+            assertEquals(ex.getMessage(), "Error invoking service contribution method "
+                    + getClass().getName()
+                    + ".contributeUnorderedWrongParameter(MappedConfiguration): Missing service.");
+        }
+
+        verify();
+    }
+
+    // From here on in, it's an almost identical code path, so we won't be
+    // as exhaustive.
+
+    @SuppressWarnings("unchecked")
+    @Test
+    public void ordered_collection_with_service_lookup()
+    {
+        OrderedConfiguration configuration = newOrderedConfiguration();
+        ServiceLocator locator = newServiceLocator();
+        UpcaseService service = newUpcaseService();
+
+        train_getService(locator, "zip.Zap", UpcaseService.class, service);
+
+        configuration.add("fred", service);
+
+        replay();
+
+        Method m = findMethod("contributeOrderedParameter");
+        ContributionDef def = new ContributionDefImpl("foo.Bar", m);
+
+        def.contribute(this, locator, configuration);
+
+        verify();
+    }
+
+    @SuppressWarnings("unchecked")
+    @Test
+    public void mapped_collection_with_service_lookup()
+    {
+        MappedConfiguration configuration = newMappedConfiguration();
+        ServiceLocator locator = newServiceLocator();
+        UpcaseService service = newUpcaseService();
+
+        train_getService(locator, "zip.Zap", UpcaseService.class, service);
+
+        configuration.add("upcase", service);
+
+        replay();
+
+        Method m = findMethod("contributeMappedParameter");
+        ContributionDef def = new ContributionDefImpl("foo.Bar", m);
+
+        def.contribute(this, locator, configuration);
+
+        verify();
+    }
+
+    private UpcaseService newUpcaseService()
+    {
+        return newMock(UpcaseService.class);
+    }
+
+    @SuppressWarnings("unchecked")
+    public void contributeUnordered(Configuration configuration)
+    {
+        configuration.add(_toContribute);
+    }
+
+    public void contributeUnorderedParameter(Configuration<UpcaseService> configuration,
+            @InjectService("zip.Zap")
+            UpcaseService service)
+    {
+        configuration.add(service);
+    }
+
+    public void contributeOrderedParameter(OrderedConfiguration<UpcaseService> configuration,
+            @InjectService("zip.Zap")
+            UpcaseService service)
+    {
+        configuration.add("fred", service);
+    }
+
+    public void contributeMappedParameter(MappedConfiguration<String, UpcaseService> configuration,
+            @InjectService("zip.Zap")
+            UpcaseService service)
+    {
+        configuration.add("upcase", service);
+    }
+
+    public void contributeUnorderedWrongParameter(MappedConfiguration configuration)
+    {
+        unreachable();
+    }
+}

Copied: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/IdMatcherImplTest.java (from r477721, tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/internal/IdMatcherImplTest.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/IdMatcherImplTest.java?view=diff&rev=477910&p1=tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/internal/IdMatcherImplTest.java&r1=477721&p2=tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/IdMatcherImplTest.java&r2=477910
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/internal/IdMatcherImplTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/IdMatcherImplTest.java Tue Nov 21 13:48:47 2006
@@ -12,71 +12,66 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.ioc.internal;
-
-import org.apache.tapestry.internal.test.InternalBaseTestCase;
-import org.apache.tapestry.ioc.IdMatcher;
-import org.apache.tapestry.ioc.internal.IdMatcherImpl;
-import org.testng.Assert;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-/**
- * 
- */
-public class IdMatcherImplTest extends InternalBaseTestCase
-{
-    @Test
-    public void invalid_pattern()
-    {
-        try
-        {
-            new IdMatcherImpl("foo");
-            unreachable();
-        }
-        catch (IllegalArgumentException ex)
-        {
-            Assert.assertEquals(
-                    ex.getMessage(),
-                    "Pattern 'foo' does not contain a '.' seperator character.");
-        }
-    }
-
-    @Test
-    public void invalid_input()
-    {
-        try
-        {
-            new IdMatcherImpl("*.*").matches("fred");
-            unreachable();
-        }
-        catch (IllegalArgumentException ex)
-        {
-            Assert.assertEquals(
-                    ex.getMessage(),
-                    "Input id 'fred' does not contain a '.' seperator character.");
-        }
-
-    }
-
-    @Test(dataProvider = "id_match_values")
-    public void id_match(String pattern, boolean expectedMatch)
-    {
-        IdMatcher matcher = new IdMatcherImpl(pattern);
-
-        Assert.assertEquals(matcher.matches("foo.bar.Baz"), expectedMatch);
-    }
-
-    @DataProvider(name = "id_match_values")
-    public Object[][] id_match_values()
-    {
-        return new Object[][]
-        {
-        { "foo*.Baz", true },
-        { "*.Baz", true },
-        { "foo.bar.*az", true },
-        { "*fie*.*az", false },
-        { "*.Goop", false } };
-    }
-
-}
+package org.apache.tapestry.ioc.internal;
+
+import org.apache.tapestry.ioc.IdMatcher;
+import org.testng.Assert;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+public class IdMatcherImplTest extends IOCInternalTestCase
+{
+    @Test
+    public void invalid_pattern()
+    {
+        try
+        {
+            new IdMatcherImpl("foo");
+            unreachable();
+        }
+        catch (IllegalArgumentException ex)
+        {
+            Assert.assertEquals(
+                    ex.getMessage(),
+                    "Pattern 'foo' does not contain a '.' seperator character.");
+        }
+    }
+
+    @Test
+    public void invalid_input()
+    {
+        try
+        {
+            new IdMatcherImpl("*.*").matches("fred");
+            unreachable();
+        }
+        catch (IllegalArgumentException ex)
+        {
+            Assert.assertEquals(
+                    ex.getMessage(),
+                    "Input id 'fred' does not contain a '.' seperator character.");
+        }
+
+    }
+
+    @Test(dataProvider = "id_match_values")
+    public void id_match(String pattern, boolean expectedMatch)
+    {
+        IdMatcher matcher = new IdMatcherImpl(pattern);
+
+        Assert.assertEquals(matcher.matches("foo.bar.Baz"), expectedMatch);
+    }
+
+    @DataProvider(name = "id_match_values")
+    public Object[][] id_match_values()
+    {
+        return new Object[][]
+        {
+        { "foo*.Baz", true },
+        { "*.Baz", true },
+        { "foo.bar.*az", true },
+        { "*fie*.*az", false },
+        { "*.Goop", false } };
+    }
+
+}

Copied: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/InterceptorStackBuilderTest.java (from r477721, tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/internal/InterceptorStackBuilderTest.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/InterceptorStackBuilderTest.java?view=diff&rev=477910&p1=tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/internal/InterceptorStackBuilderTest.java&r1=477721&p2=tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/InterceptorStackBuilderTest.java&r2=477910
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/internal/InterceptorStackBuilderTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/InterceptorStackBuilderTest.java Tue Nov 21 13:48:47 2006
@@ -12,104 +12,101 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.ioc.internal;
-
-import static java.util.Arrays.asList;
+package org.apache.tapestry.ioc.internal;
+
+import static java.util.Arrays.asList;
 import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newList;
-
-import java.util.List;
-
-import org.apache.tapestry.internal.test.InternalBaseTestCase;
-import org.apache.tapestry.ioc.ObjectCreator;
-import org.apache.tapestry.ioc.ServiceDecorator;
-import org.apache.tapestry.ioc.internal.InterceptorStackBuilder;
-import org.apache.tapestry.ioc.internal.Module;
-import org.testng.annotations.Test;
-
-public class InterceptorStackBuilderTest extends InternalBaseTestCase
-{
-    private static final String SERVICE_ID = "foo.bar.Baz";
-
-    @Test
-    public void no_decorators()
-    {
-        ObjectCreator core = newObjectCreator();
-        Module module = newModule();
-        Object coreObject = new Object();
-        List<ServiceDecorator> decorators = newList();
-
-        train_createObject(core, coreObject);
-
-        train_findDecoratorsForService(module, SERVICE_ID, decorators);
-
-        replay();
-
-        ObjectCreator isb = new InterceptorStackBuilder(module, SERVICE_ID, core);
-
-        Object intercepted = isb.createObject();
-
-        assertSame(intercepted, coreObject);
-
-        verify();
-    }
-
-    @Test
-    public void decorator_returns_null_interceptor()
-    {
-        ObjectCreator core = newObjectCreator();
-        Module module = newModule();
-        Object coreObject = new Object();
-        ServiceDecorator decorator = newServiceDecorator();
-
-        List<ServiceDecorator> decorators = asList(decorator);
-
-        train_createObject(core, coreObject);
-
-        train_findDecoratorsForService(module, SERVICE_ID, decorators);
-
-        train_createInterceptor(decorator, coreObject, null);
-
-        replay();
-
-        ObjectCreator isb = new InterceptorStackBuilder(module, SERVICE_ID, core);
-
-        Object intercepted = isb.createObject();
-
-        assertSame(intercepted, coreObject);
-
-        verify();
-    }
-
-    @Test
-    public void decorator_orderering()
-    {
-        ObjectCreator core = newObjectCreator();
-        Module module = newModule();
-        Object coreObject = new Object();
-        Object interceptor1 = new Object();
-        Object interceptor2 = new Object();
-        ServiceDecorator decorator1 = newServiceDecorator();
-        ServiceDecorator decorator2 = newServiceDecorator();
-
-        List<ServiceDecorator> decorators = asList(decorator1, decorator2);
-
-        train_createObject(core, coreObject);
-
-        train_findDecoratorsForService(module, SERVICE_ID, decorators);
-
-        // Notice: reverse order!
-
-        train_createInterceptor(decorator2, coreObject, interceptor2);
-        train_createInterceptor(decorator1, interceptor2, interceptor1);
-
-        replay();
-
-        ObjectCreator isb = new InterceptorStackBuilder(module, SERVICE_ID, core);
-
-        Object intercepted = isb.createObject();
-
-        assertSame(intercepted, interceptor1);
-
-        verify();
-    }
-}
+
+import java.util.List;
+
+import org.apache.tapestry.ioc.ObjectCreator;
+import org.apache.tapestry.ioc.ServiceDecorator;
+import org.testng.annotations.Test;
+
+public class InterceptorStackBuilderTest extends IOCInternalTestCase
+{
+    private static final String SERVICE_ID = "foo.bar.Baz";
+
+    @Test
+    public void no_decorators()
+    {
+        ObjectCreator core = newObjectCreator();
+        Module module = newModule();
+        Object coreObject = new Object();
+        List<ServiceDecorator> decorators = newList();
+
+        train_createObject(core, coreObject);
+
+        train_findDecoratorsForService(module, SERVICE_ID, decorators);
+
+        replay();
+
+        ObjectCreator isb = new InterceptorStackBuilder(module, SERVICE_ID, core);
+
+        Object intercepted = isb.createObject();
+
+        assertSame(intercepted, coreObject);
+
+        verify();
+    }
+
+    @Test
+    public void decorator_returns_null_interceptor()
+    {
+        ObjectCreator core = newObjectCreator();
+        Module module = newModule();
+        Object coreObject = new Object();
+        ServiceDecorator decorator = newServiceDecorator();
+
+        List<ServiceDecorator> decorators = asList(decorator);
+
+        train_createObject(core, coreObject);
+
+        train_findDecoratorsForService(module, SERVICE_ID, decorators);
+
+        train_createInterceptor(decorator, coreObject, null);
+
+        replay();
+
+        ObjectCreator isb = new InterceptorStackBuilder(module, SERVICE_ID, core);
+
+        Object intercepted = isb.createObject();
+
+        assertSame(intercepted, coreObject);
+
+        verify();
+    }
+
+    @Test
+    public void decorator_orderering()
+    {
+        ObjectCreator core = newObjectCreator();
+        Module module = newModule();
+        Object coreObject = new Object();
+        Object interceptor1 = new Object();
+        Object interceptor2 = new Object();
+        ServiceDecorator decorator1 = newServiceDecorator();
+        ServiceDecorator decorator2 = newServiceDecorator();
+
+        List<ServiceDecorator> decorators = asList(decorator1, decorator2);
+
+        train_createObject(core, coreObject);
+
+        train_findDecoratorsForService(module, SERVICE_ID, decorators);
+
+        // Notice: reverse order!
+
+        train_createInterceptor(decorator2, coreObject, interceptor2);
+        train_createInterceptor(decorator1, interceptor2, interceptor1);
+
+        replay();
+
+        ObjectCreator isb = new InterceptorStackBuilder(module, SERVICE_ID, core);
+
+        Object intercepted = isb.createObject();
+
+        assertSame(intercepted, interceptor1);
+
+        verify();
+    }
+}