You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2006/07/14 18:52:44 UTC

svn commit: r421946 [1/2] - in /tapestry/tapestry5/tapestry-core/trunk/src: main/aspect/org/apache/tapestry/internal/aspects/ main/java/org/apache/tapestry/internal/ioc/ main/java/org/apache/tapestry/internal/util/ main/java/org/apache/tapestry/ioc/ ma...

Author: hlship
Date: Fri Jul 14 09:52:41 2006
New Revision: 421946

URL: http://svn.apache.org/viewvc?rev=421946&view=rev
Log:
Use Neil Ford's naming convention for test methods.
Refactor the HiveMind Orderer utility for use inside Tapestry 5 (using generics, etc.).

Added:
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/DependencyNode.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/Orderer.java   (contents, props changed)
      - copied, changed from r386879, jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/order/Orderer.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/Orderable.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/util/OrdererTest.java
Modified:
    tapestry/tapestry5/tapestry-core/trunk/src/main/aspect/org/apache/tapestry/internal/aspects/UtilityChecks.aj
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/BasicServiceCreator.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImpl.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/IOCMessages.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ModuleImpl.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ServiceDefImpl.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/UtilMessages.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/def/ServiceDef.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/BaseTestCase.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/transform/MethodSignature.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/util/CollectionFactory.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/util/IdAllocator.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/internal/util/UtilStrings.properties
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/CatchNullParametersAspectTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/InternalUtilityAspectTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/SynchronizationAspectTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/BasicServiceCreatorTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImplTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ModuleImplTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/pageload/ComponentTemplateSourceImplTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/parser/TemplateParserImplTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/UpdateListenerHubImplTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/ComponentInstantiatorSourceImplTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/InternalClassTransformationImplTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/worker/RetainWorkerTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/worker/UnclaimedFieldWorkerTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/util/URLChangeTrackerTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/ErrorLogImplTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/RegistryBuilderTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/transform/MethodSignatureTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/util/CollectionFactoryTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/util/DefenseTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/util/IdAllocatorTest.java

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/aspect/org/apache/tapestry/internal/aspects/UtilityChecks.aj
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/aspect/org/apache/tapestry/internal/aspects/UtilityChecks.aj?rev=421946&r1=421945&r2=421946&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/aspect/org/apache/tapestry/internal/aspects/UtilityChecks.aj (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/aspect/org/apache/tapestry/internal/aspects/UtilityChecks.aj Fri Jul 14 09:52:41 2006
@@ -41,7 +41,7 @@
     {
         String message = String
                 .format(
-                        "Class %s has been marked as a utility class (with the @Utility annotation) and can not be instantiated.",
+                        "Class %s has been marked as a utility class (with the @Utility annotation) and may not be instantiated.",
                         thisJoinPoint.getThis().getClass().getName());
 
         throw new RuntimeException(message);

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/BasicServiceCreator.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/BasicServiceCreator.java?rev=421946&r1=421945&r2=421946&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/BasicServiceCreator.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/BasicServiceCreator.java Fri Jul 14 09:52:41 2006
@@ -14,6 +14,8 @@
 
 package org.apache.tapestry.internal.ioc;
 
+import static org.apache.tapestry.util.CollectionFactory.newMap;
+
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 import java.util.Map;
@@ -25,12 +27,10 @@
 import org.apache.tapestry.ioc.annotations.InjectService;
 import org.apache.tapestry.ioc.def.ServiceDef;
 
-import static org.apache.tapestry.util.CollectionFactory.newMap;
-
 /**
- * Basic implementation of {@link org.apache.tapestry.ioc.ServiceCreator} that handles
- * invoking a method on the module builder, and figures out the correct parameters to pass into the
- * annotated method.
+ * Basic implementation of {@link org.apache.tapestry.ioc.ServiceCreator} that handles invoking a
+ * method on the module builder, and figures out the correct parameters to pass into the annotated
+ * method.
  * 
  * @author Howard M. Lewis Ship
  */
@@ -48,11 +48,14 @@
 
     private final ServiceResources _resources;
 
-    public BasicServiceCreator(ServiceDef serviceDef, Object moduleBuilder,
+    private final Method _builderMethod;
+
+    public BasicServiceCreator(ServiceDef serviceDef, Method method, Object moduleBuilder,
             ServiceResources resources)
     {
         _serviceId = serviceDef.getServiceId();
         _serviceDef = serviceDef;
+        _builderMethod = method;
         _moduleBuilder = moduleBuilder;
         _log = resources.getErrorLog();
         _resources = resources;
@@ -69,10 +72,8 @@
      */
     public Object createService()
     {
-        Method m = _serviceDef.getBuilderMethod();
-
-        Class[] parameterTypes = m.getParameterTypes();
-        Annotation[][] annotations = m.getParameterAnnotations();
+        Class[] parameterTypes = _builderMethod.getParameterTypes();
+        Annotation[][] annotations = _builderMethod.getParameterAnnotations();
         int parameterCount = parameterTypes.length;
 
         Object[] parameters = new Object[parameterCount];
@@ -86,15 +87,20 @@
 
         try
         {
-            result = m.invoke(_moduleBuilder, parameters);
+            result = _builderMethod.invoke(_moduleBuilder, parameters);
         }
         catch (Exception ex)
         {
-            throw new RuntimeException(IOCMessages.builderMethodError(m, _serviceId, ex), ex);
+            throw new RuntimeException(IOCMessages.builderMethodError(
+                    _builderMethod,
+                    _serviceId,
+                    ex), ex);
         }
 
         if (result == null)
-            throw new RuntimeException(IOCMessages.builderMethodReturnedNull(m, _serviceId));
+            throw new RuntimeException(IOCMessages.builderMethodReturnedNull(
+                    _builderMethod,
+                    _serviceId));
 
         return result;
     }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImpl.java?rev=421946&r1=421945&r2=421946&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImpl.java Fri Jul 14 09:52:41 2006
@@ -160,7 +160,7 @@
 
         if (existing != null)
         {
-            _log.warn(buildMethodConflict(method, existing.getBuilderMethod()), null);
+            _log.warn(buildMethodConflict(method, existing.toString()), null);
             return;
         }
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/IOCMessages.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/IOCMessages.java?rev=421946&r1=421945&r2=421946&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/IOCMessages.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/IOCMessages.java Fri Jul 14 09:52:41 2006
@@ -20,6 +20,7 @@
 import org.apache.hivemind.Messages;
 import org.apache.hivemind.impl.MessageFormatter;
 import org.apache.tapestry.internal.annotations.Utility;
+import org.apache.tapestry.ioc.def.ServiceDef;
 
 /**
  * @author Howard M. Lewis Ship
@@ -29,7 +30,7 @@
 {
     private static final Messages MESSAGES = new MessageFormatter(IOCMessages.class);
 
-    static String buildMethodConflict(Method conflict, Method existing)
+    static String buildMethodConflict(Method conflict, String existing)
     {
         return MESSAGES.format("build-method-conflict", conflict, existing);
     }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ModuleImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ModuleImpl.java?rev=421946&r1=421945&r2=421946&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ModuleImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ModuleImpl.java Fri Jul 14 09:52:41 2006
@@ -165,8 +165,10 @@
 
         ServiceResources resources = new ServiceResourcesImpl(_registry, this, def);
 
+        ServiceCreator coreCreator = def.createServiceCreator(_moduleBuilder, resources);
+
         ServiceCreator creator = new LifecycleWrappedServiceCreator(lifecycle, resources,
-                new BasicServiceCreator(def, _moduleBuilder, resources));
+                coreCreator);
 
         // TODO: Somewhere, in here, we have to add a chance for decorators to
         // create interceptors for the service.

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ServiceDefImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ServiceDefImpl.java?rev=421946&r1=421945&r2=421946&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ServiceDefImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ServiceDefImpl.java Fri Jul 14 09:52:41 2006
@@ -16,6 +16,8 @@
 
 import java.lang.reflect.Method;
 
+import org.apache.tapestry.ioc.ServiceCreator;
+import org.apache.tapestry.ioc.ServiceResources;
 import org.apache.tapestry.ioc.def.ServiceDef;
 
 /**
@@ -39,9 +41,19 @@
         _private = isprivate;
     }
 
-    public Method getBuilderMethod()
+    public String toString()
+    {
+        return _builderMethod.toString();
+    }
+
+    Method getBuilderMethod()
     {
         return _builderMethod;
+    }
+
+    public ServiceCreator createServiceCreator(Object moduleBuilder, ServiceResources resources)
+    {
+        return new BasicServiceCreator(this, _builderMethod, moduleBuilder, resources);
     }
 
     public String getServiceId()

Added: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/DependencyNode.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/DependencyNode.java?rev=421946&view=auto
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/DependencyNode.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/DependencyNode.java Fri Jul 14 09:52:41 2006
@@ -0,0 +1,147 @@
+// 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.
+
+/**
+ * 
+ */
+package org.apache.tapestry.internal.util;
+
+import static org.apache.tapestry.util.CollectionFactory.newList;
+
+import java.util.List;
+
+import org.apache.tapestry.internal.annotations.SuppressNullCheck;
+import org.apache.tapestry.ioc.ErrorLog;
+import org.apache.tapestry.ioc.Orderable;
+
+/**
+ * Used by {@link org.apache.tapestry.internal.util.Orderer} to establish backward dependencies for
+ * {@link org.apache.tapestry.ioc.Orderable} objects.
+ * 
+ * @param <T>
+ */
+@SuppressNullCheck
+class DependencyNode<T>
+{
+    private final ErrorLog _errorLog;
+
+    private final Orderable<T> _orderable;
+
+    private final List<DependencyNode<T>> _dependencies = newList();
+
+    DependencyNode(ErrorLog errorLog, Orderable<T> orderable)
+    {
+        _errorLog = errorLog;
+        _orderable = orderable;
+    }
+
+    @Override
+    public String toString()
+    {
+        StringBuffer buffer = new StringBuffer(String.format("[%s", getId()));
+
+        boolean first = true;
+
+        for (DependencyNode<T> node : _dependencies)
+        {
+
+            buffer.append(first ? ": " : ", ");
+
+            buffer.append(node.toString());
+
+            first = false;
+        }
+
+        buffer.append("]");
+
+        return buffer.toString();
+    }
+
+    /**
+     * Returns the underlying {@link Orderable}'s id.
+     */
+    public String getId()
+    {
+        return _orderable.getId();
+    }
+
+    void addDependency(DependencyNode<T> node)
+    {
+        if (node.isReachable(this))
+        {
+            String message = UtilMessages.dependencyCycle(node, this);
+            _errorLog.warn(message, null);
+            return;
+        }
+
+        // Make this node depend on the other node.
+        // That forces the other node's orderable
+        // to appear before this node's orderable.
+
+        _dependencies.add(node);
+    }
+
+    boolean isReachable(DependencyNode<T> node)
+    {
+        if (this == node)
+            return true;
+
+        // Quick fast pass for immediate dependencies
+
+        for (DependencyNode<T> d : _dependencies)
+        {
+            if (d == node)
+                return true;
+        }
+
+        // Slower second pass looks for
+        // indirect dependencies
+
+        for (DependencyNode<T> d : _dependencies)
+        {
+            if (d.isReachable(node))
+                return true;
+        }
+
+        return false;
+    }
+
+    /**
+     * Returns the {@link Orderable} objects for this node ordered based on dependencies.
+     */
+    List<Orderable<T>> getOrdered()
+    {
+        List<Orderable<T>> result = newList();
+
+        fillOrder(result);
+
+        return result;
+    }
+
+    private void fillOrder(List<Orderable<T>> list)
+    {
+        if (list.contains(_orderable))
+            return;
+
+        // Recusively add dependencies
+
+        for (DependencyNode<T> node : _dependencies)
+        {
+            node.fillOrder(list);
+        }
+
+        list.add(_orderable);
+    }
+
+}
\ No newline at end of file

Copied: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/Orderer.java (from r386879, jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/order/Orderer.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/Orderer.java?p2=tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/Orderer.java&p1=jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/order/Orderer.java&r1=386879&r2=421946&rev=421946&view=diff
==============================================================================
--- jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/order/Orderer.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/Orderer.java Fri Jul 14 09:52:41 2006
@@ -12,24 +12,18 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.hivemind.order;
+package org.apache.tapestry.internal.util;
+
+import static org.apache.tapestry.util.CollectionFactory.newList;
+import static org.apache.tapestry.util.CollectionFactory.newMap;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hivemind.ApplicationRuntimeException;
-import org.apache.hivemind.ErrorHandler;
-import org.apache.hivemind.ErrorLog;
-import org.apache.hivemind.HiveMind;
-import org.apache.hivemind.impl.ErrorLogImpl;
-import org.apache.hivemind.util.Defense;
 import org.apache.hivemind.util.StringUtils;
+import org.apache.tapestry.internal.annotations.SuppressNullCheck;
+import org.apache.tapestry.ioc.ErrorLog;
+import org.apache.tapestry.ioc.Orderable;
 
 /**
  * Used to order objects into an "execution" order. Each object must have a name. It may specify a
@@ -37,132 +31,71 @@
  * 
  * @author Howard Lewis Ship
  */
-public class Orderer
+public class Orderer<T>
 {
     private final ErrorLog _errorLog;
 
-    private final String _objectType;
-
-    private List _orderingsList = null;
-
-    private Map _orderingsMap = null;
+    private final List<Orderable> _orderables = newList();
 
-    private Map _nodeMap = null;
+    private final Map<String, Orderable> _orderablesById = newMap();
 
-    private Node _leader;
+    private final Map<String, DependencyNode<T>> _dependencyNodesById = newMap();
 
-    private Node _trailer;
+    private DependencyNode<T> _leader;
 
-    /**
-     * Creates an instance using <code>org.apache.hivemind.order.Orderer</code> as the Log.
-     */
-    public Orderer(ErrorHandler errorHandler, String objectType)
-    {
-        this(LogFactory.getLog(Orderer.class), errorHandler, objectType);
-    }
+    private DependencyNode<T> _trailer;
 
-    /**
-     * Creates a new instance, but directs all debug and error logging output to the provided log.
-     * 
-     * @param log
-     *            Used for logging any errors
-     * @param objectType
-     *            user presentable name for the type of object to be ordered; used in some error
-     *            messages
-     */
-    public Orderer(Log log, ErrorHandler errorHandler, String objectType)
+    public Orderer(ErrorLog errorLog)
     {
-        this(new ErrorLogImpl(errorHandler, log), objectType);
-    }
-
-    /**
-     * Creates a new instance.
-     * 
-     * @param errorLog
-     *            Used for log any recoverable errors.
-     * @param objectType
-     *            user presentable name for the type of object to be ordered; used in some error
-     *            messages
-     */
-    public Orderer(ErrorLog errorLog, String objectType)
-    {
-        Defense.notNull(errorLog, "errorLog");
-        Defense.notNull(objectType, "objectType");
-
         _errorLog = errorLog;
-        _objectType = objectType;
     }
 
-    /**
-     * Adds a new object. All invocations of {@link #add(Object, String, String, String)} should
-     * occur before invoking {@link #getOrderedObjects()}.
-     * 
-     * @param object
-     *            an object to be sorted into order based on prereqs and postreqs
-     * @param name
-     *            a unique name for the
-     * @param prereqs
-     *            a comma-separated list of the names of objects that should precede this object in
-     *            the list (or null)
-     * @param postreqs
-     *            a comma-separated list of the names of objects that should follow this object in
-     *            the list (or null)
-     */
-    public void add(Object object, String name, String prereqs, String postreqs)
+    public void add(Orderable<T> orderable)
     {
-        if (_orderingsMap == null)
-        {
-            _orderingsMap = new HashMap();
-            _orderingsList = new ArrayList();
-        }
+        String id = orderable.getId();
 
-        ObjectOrdering o = getOrderable(name);
-
-        if (o != null)
+        if (_orderablesById.containsKey(id))
         {
-            _errorLog.error(
-                    OrdererMessages.duplicateName(_objectType, name, object, o.getObject()),
-                    HiveMind.getLocation(object),
-                    null);
-
+            _errorLog.warn(UtilMessages.duplicateOrderer(id), null);
             return;
         }
 
-        o = new ObjectOrdering(object, name, prereqs, postreqs);
+        _orderables.add(orderable);
 
-        _orderingsMap.put(name, o);
-        _orderingsList.add(o);
+        _orderablesById.put(id, orderable);
     }
 
-    private ObjectOrdering getOrderable(String name)
+    @SuppressNullCheck
+    public void add(String id, T target)
     {
-        return (ObjectOrdering) _orderingsMap.get(name);
+        add(new Orderable(id, target));
     }
 
-    /**
-     * Uses the information provided by {@link #add(Object, String, String, String)} to order the
-     * objects into an appropriate order based on the pre- and post-reqts provided. Errors such as
-     * cyclic dependencies or unrecognized names are logged and ignored.
-     */
-    public List getOrderedObjects()
+    @SuppressNullCheck
+    public void add(String id, String prereqs, String postreqs, T target)
     {
-        if (_orderingsMap == null)
-            return Collections.EMPTY_LIST;
+        add(new Orderable(id, prereqs, postreqs, target));
+    }
 
-        try
-        {
-            _nodeMap = new HashMap();
+    public List<T> getOrdered()
+    {
+        // TODO: Prevent method from being invoked twice!
 
-            initializeGraph();
+        initializeGraph();
 
-            return _trailer.getOrder();
-        }
-        finally
+        List<T> result = newList();
+
+        for (Orderable<T> orderable : _trailer.getOrdered())
         {
-            _nodeMap = null;
-            _leader = null;
-            _trailer = null;
+            T target = orderable.getTarget();
+
+            // Nulls are placeholders that are skipped.
+
+            if (target != null)
+                result.add(target);
         }
+
+        return result;
     }
 
     private void initializeGraph()
@@ -170,50 +103,40 @@
         addNodes();
 
         if (_leader == null)
-            _leader = new Node(null, "*-leader-*");
+            _leader = new DependencyNode(_errorLog, new Orderable<T>("*-leader-*", null));
 
         if (_trailer == null)
-            _trailer = new Node(null, "*-trailer-*");
+            _trailer = new DependencyNode(_errorLog, new Orderable<T>("*-trailer-*", null));
 
         addDependencies();
     }
 
-    private Node getNode(String name)
-    {
-        return (Node) _nodeMap.get(getOrderable(name));
-    }
-
     private void addNodes()
     {
-        Iterator i = _orderingsList.iterator();
-
-        while (i.hasNext())
+        for (Orderable<T> orderable : _orderables)
         {
-            ObjectOrdering o = (ObjectOrdering) i.next();
+            DependencyNode<T> node = new DependencyNode<T>(_errorLog, orderable);
 
-            Node node = new Node(o.getObject(), o.getName());
+            _dependencyNodesById.put(orderable.getId(), node);
 
-            _nodeMap.put(o, node);
-
-            if ("*".equals(o.getPostreqs()))
+            if ("*".equals(orderable.getPostreqs()))
             {
                 if (_leader == null)
                     _leader = node;
                 else
-                    _errorLog.error(OrdererMessages.dupeLeader(_objectType, o, getOrderable(_leader
-                            .getName())), HiveMind.getLocation(o.getObject()), null);
+                {
+                    _errorLog.warn(UtilMessages.duplicateLeader(node, _leader), null);
+                }
             }
 
-            if ("*".equals(o.getPrereqs()))
+            if ("*".equals(orderable.getPrereqs()))
             {
                 if (_trailer == null)
                     _trailer = node;
                 else
-                    _errorLog.error(
-                            OrdererMessages.dupeTrailer(_objectType, o, getOrderable(_trailer
-                                    .getName())),
-                            HiveMind.getLocation(o.getObject()),
-                            null);
+                {
+                    _errorLog.warn(UtilMessages.duplicateTrailer(node, _trailer), null);
+                }
             }
 
         }
@@ -221,186 +144,77 @@
 
     private void addDependencies()
     {
-        Iterator i = _orderingsList.iterator();
-
-        while (i.hasNext())
+        for (Orderable<T> orderable : _orderables)
         {
-            ObjectOrdering o = (ObjectOrdering) i.next();
-
-            addDependencies(o, getNode(o.getName()));
+            addDependencies(orderable);
         }
     }
 
-    private void addDependencies(ObjectOrdering orderable, Node node)
+    private void addDependencies(Orderable<T> orderable)
     {
+        DependencyNode<T> node = _dependencyNodesById.get(orderable.getId());
+
         addPreRequisites(orderable, node);
         addPostRequisites(orderable, node);
 
-        try
-        {
-            if (node != _leader)
-                node.addDependency(_leader);
+        // The leader node is dependened upon by every other
+        // node.
 
-            if (node != _trailer)
-                _trailer.addDependency(node);
-        }
-        catch (ApplicationRuntimeException ex)
-        {
-            // This code is unreachable ... but nonetheless.
+        if (node != _leader)
+            node.addDependency(_leader);
 
-            String name = node.getName();
-            ObjectOrdering trigger = getOrderable(name);
+        // The trailer dependes upon every other node.
+
+        if (node != _trailer)
+            _trailer.addDependency(node);
 
-            _errorLog.error(OrdererMessages.dependencyCycle(_objectType, orderable, ex), HiveMind
-                    .getLocation(trigger.getObject()), ex);
-        }
     }
 
-    private void addPreRequisites(ObjectOrdering ordering, Node node)
+    private void addPreRequisites(Orderable<T> orderable, DependencyNode<T> node)
     {
-        String prereqs = ordering.getPrereqs();
+        String prereqs = orderable.getPrereqs();
 
         if ("*".equals(prereqs))
             return;
 
-        String[] names = StringUtils.split(prereqs);
-
-        for (int i = 0; i < names.length; i++)
+        for (String id : StringUtils.split(prereqs))
         {
-            String prename = names[i];
+            DependencyNode<T> dependency = _dependencyNodesById.get(id);
 
-            Node prenode = getNode(prename);
-
-            if (prenode == null)
+            if (dependency == null)
             {
-                _errorLog.error(
-                        OrdererMessages.badDependency(_objectType, prename, ordering),
-                        HiveMind.getLocation(ordering.getObject()),
-                        null);
-                continue;
-            }
-
-            try
-            {
-                node.addDependency(prenode);
+                return;
             }
-            catch (ApplicationRuntimeException ex)
+            else
             {
-                _errorLog.error(
-                        OrdererMessages.dependencyCycle(_objectType, ordering, ex),
-                        HiveMind.getLocation(ordering.getObject()),
-                        ex);
+                // id is a pre-requisite of the node, so add the dependency
+                // to the node.
+                node.addDependency(dependency);
             }
-
         }
     }
 
-    private void addPostRequisites(ObjectOrdering ordering, Node node)
+    private void addPostRequisites(Orderable<T> orderable, DependencyNode<T> node)
     {
-        String postreqs = ordering.getPostreqs();
+        String postreqs = orderable.getPostreqs();
 
         if ("*".equals(postreqs))
             return;
 
-        String[] names = StringUtils.split(postreqs);
-
-        for (int i = 0; i < names.length; i++)
+        for (String id : StringUtils.split(postreqs))
         {
-            String postname = names[i];
+            DependencyNode<T> dependant = _dependencyNodesById.get(id);
 
-            Node postnode = getNode(postname);
-
-            if (postnode == null)
+            if (dependant == null)
             {
-                _errorLog.error(
-                        OrdererMessages.badDependency(_objectType, postname, ordering),
-                        HiveMind.getLocation(ordering.getObject()),
-                        null);
+                // TODO!
             }
             else
             {
-                try
-                {
-                    postnode.addDependency(node);
-                }
-                catch (ApplicationRuntimeException ex)
-                {
-                    _errorLog.error(
-                            OrdererMessages.dependencyCycle(_objectType, ordering, ex),
-                            HiveMind.getLocation(ordering.getObject()),
-                            ex);
-                }
+                // id is a post-requisite, so we reverse it, and make the
+                // node identify by id dependent on this node.
+                dependant.addDependency(node);
             }
-        }
-    }
-
-    private static class Node
-    {
-        private Object _object;
-
-        private String _name;
-
-        private List _dependencies;
-
-        public Node(Object o, String name)
-        {
-            _object = o;
-            _name = name;
-            _dependencies = new ArrayList();
-        }
-
-        public String getName()
-        {
-            return _name;
-        }
-
-        public void addDependency(Node n)
-        {
-            if (n.isReachable(this))
-                throw new ApplicationRuntimeException(
-                        "A cycle has been detected from the initial object [" + _name + "]",
-                        HiveMind.getLocation(_object), null);
-
-            _dependencies.add(n);
-        }
-
-        private boolean isReachable(Node n)
-        {
-            boolean reachable = (n == this);
-            Iterator i = _dependencies.iterator();
-
-            while (i.hasNext() && !reachable)
-            {
-                Node dep = (Node) i.next();
-                reachable = (dep == n) ? true : dep.isReachable(n);
-            }
-
-            return reachable;
-        }
-
-        public List getOrder()
-        {
-            List result = new ArrayList();
-            fillOrder(result);
-
-            return result;
-        }
-
-        private void fillOrder(List result)
-        {
-            if (result.contains(_object))
-                return;
-
-            Iterator i = _dependencies.iterator();
-
-            while (i.hasNext())
-            {
-                Node dep = (Node) i.next();
-                dep.fillOrder(result);
-            }
-
-            if (_object != null)
-                result.add(_object);
         }
     }
 

Propchange: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/Orderer.java
------------------------------------------------------------------------------
    cvs2svn:cvs-rev = 1.15

Propchange: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/Orderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/Orderer.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/UtilMessages.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/UtilMessages.java?rev=421946&r1=421945&r2=421946&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/UtilMessages.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/UtilMessages.java Fri Jul 14 09:52:41 2006
@@ -32,4 +32,24 @@
     {
         return MESSAGES.format("unable-to-read-last-modified", url, cause);
     }
+
+    static String dependencyCycle(DependencyNode dependency, DependencyNode node)
+    {
+        return MESSAGES.format("dependency-cycle", dependency.getId(), node.getId());
+    }
+
+    static String duplicateOrderer(String id)
+    {
+        return MESSAGES.format("duplicate-orderer", id);
+    }
+
+    static String duplicateTrailer(DependencyNode newTrailer, DependencyNode existingTrailer)
+    {
+        return MESSAGES.format("duplicate-trailer", newTrailer.getId(), existingTrailer.getId());
+    }
+
+    static String duplicateLeader(DependencyNode newTrailer, DependencyNode existingTrailer)
+    {
+        return MESSAGES.format("duplicate-leader", newTrailer.getId(), existingTrailer.getId());
+    }
 }

Added: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/Orderable.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/Orderable.java?rev=421946&view=auto
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/Orderable.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/Orderable.java Fri Jul 14 09:52:41 2006
@@ -0,0 +1,114 @@
+// 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.
+
+package org.apache.tapestry.ioc;
+
+import static org.apache.tapestry.util.Defense.notBlank;
+
+import java.io.Serializable;
+
+import org.apache.hivemind.HiveMind;
+import org.apache.tapestry.internal.annotations.SuppressNullCheck;
+
+/**
+ * A wrapper that allows objects of a target type to be ordered. Each Orderable object is given a
+ * unique id and a set of pre-requisites (objects which should be ordered earlier) and
+ * post-requisites (objects which should be ordered later).
+ * 
+ * @param <T>
+ */
+public class Orderable<T> implements Serializable
+{
+    private static final long serialVersionUID = -5133760853920427942L;
+
+    private final String _id;
+
+    private final String _prereqs;
+
+    private final String _postreqs;
+
+    private final T _target;
+
+    /**
+     * @param id
+     *            unique identifier for the target object
+     * @param prereqs
+     *            list of preceding objects, or "*" to order this object last, or null to not care
+     * @param postreqs
+     *            list of following objects, or "*" to order this object last, or null to not care
+     * @param target
+     *            the object to be ordered; this may also be null (in which case the id represents a
+     *            placeholder)
+     */
+    @SuppressNullCheck
+    public Orderable(String id, String prereqs, String postreqs, T target)
+    {
+        _id = notBlank(id, "id");
+        _prereqs = prereqs;
+        _postreqs = postreqs;
+        _target = target;
+    }
+
+    @SuppressNullCheck
+    public Orderable(String id, T target)
+    {
+        this(id, null, null, target);
+    }
+
+    public String getId()
+    {
+        return _id;
+    }
+
+    public String getPostreqs()
+    {
+        return _postreqs;
+    }
+
+    public String getPrereqs()
+    {
+        return _prereqs;
+    }
+
+    public T getTarget()
+    {
+        return _target;
+    }
+
+    @Override
+    public String toString()
+    {
+        StringBuffer buffer = new StringBuffer("Orderable[");
+
+        buffer.append(_id);
+
+        if (HiveMind.isNonBlank(_prereqs))
+        {
+            buffer.append(" pre:");
+            buffer.append(_prereqs);
+        }
+
+        if (HiveMind.isNonBlank(_postreqs))
+        {
+            buffer.append(" post:");
+            buffer.append(_postreqs);
+        }
+
+        buffer.append(" ");
+        buffer.append(_target.toString());
+        buffer.append("]");
+
+        return buffer.toString();
+    }
+}

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/def/ServiceDef.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/def/ServiceDef.java?rev=421946&r1=421945&r2=421946&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/def/ServiceDef.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/def/ServiceDef.java Fri Jul 14 09:52:41 2006
@@ -14,21 +14,26 @@
 
 package org.apache.tapestry.ioc.def;
 
-import java.lang.reflect.Method;
+import org.apache.tapestry.ioc.ServiceCreator;
+import org.apache.tapestry.ioc.ServiceResources;
 
 /**
- * Service definition.
+ * Service definition derived, by default, from a service builder method.
  * 
  * @author Howard M. Lewis Ship
  */
 public interface ServiceDef
 {
     /**
-     * Returns the method to invoke, on the corresponding module builder instance, that will provide
-     * the core service implementation. This method is also the source of any annotations concerning
-     * the service.
+     * Returns a {@link ServiceCreator} that can create the core service implementation.
+     * 
+     * @param moduleBuilder
+     *            the module builder instance for the module containing the service
+     * @param resources
+     *            used to resolve dependencies of the service
+     * @return an object that can (later) be used to instantiate the service itself
      */
-    Method getBuilderMethod();
+    ServiceCreator createServiceCreator(Object moduleBuilder, ServiceResources resources);
 
     /** Returns the fully qualified service id, derived from the method name. */
     String getServiceId();

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/BaseTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/BaseTestCase.java?rev=421946&r1=421945&r2=421946&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/BaseTestCase.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/BaseTestCase.java Fri Jul 14 09:52:41 2006
@@ -14,14 +14,17 @@
 
 package org.apache.tapestry.test;
 
+import static java.lang.Thread.sleep;
+import static org.apache.tapestry.util.CollectionFactory.newList;
+
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.OutputStream;
 import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLClassLoader;
+import java.util.Arrays;
 import java.util.List;
 import java.util.UUID;
 
@@ -35,9 +38,6 @@
 import org.apache.tapestry.model.MutableComponentModel;
 import org.apache.tapestry.transform.ClassTransformation;
 
-import static java.lang.Thread.sleep;
-import static org.apache.tapestry.util.CollectionFactory.newList;
-
 /**
  * Base test case that adds a number of convienience factory and training methods to
  * {@link org.apache.tapestry.test.TestBase}.
@@ -50,7 +50,7 @@
     protected final void trainFindFieldsWithAnnotation(ClassTransformation transformation,
             Class<? extends Annotation> annotationClass, String... fieldNames)
     {
-        trainFindFieldsWithAnnotation(transformation, annotationClass, newList(fieldNames));
+        trainFindFieldsWithAnnotation(transformation, annotationClass, Arrays.asList(fieldNames));
     }
 
     protected final void trainFindFieldsWithAnnotation(ClassTransformation transformation,
@@ -154,12 +154,6 @@
         return newMock(Resource.class);
     }
 
-    protected final void trainGetBuilderMethod(ServiceDef def, Method m)
-    {
-        def.getBuilderMethod();
-        setReturnValue(m);
-    }
-
     protected final void trainGetServiceInterface(ServiceDef def, Class serviceInterface)
     {
         def.getServiceInterface();
@@ -192,16 +186,18 @@
     {
         resources.getServiceLog();
         setReturnValue(log);
-    
+
     }
 
-    protected final <T> void trainGetService(ServiceResources resources, String serviceId, Class<T> serviceInterface, T service)
+    protected final <T> void trainGetService(ServiceResources resources, String serviceId,
+            Class<T> serviceInterface, T service)
     {
         resources.getService(serviceId, serviceInterface);
         setReturnValue(service);
     }
 
-    protected final <T> void trainGetService(ServiceResources resources, Class<T> serviceInterface, T service)
+    protected final <T> void trainGetService(ServiceResources resources, Class<T> serviceInterface,
+            T service)
     {
         resources.getService(serviceInterface);
         setReturnValue(service);

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/transform/MethodSignature.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/transform/MethodSignature.java?rev=421946&r1=421945&r2=421946&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/transform/MethodSignature.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/transform/MethodSignature.java Fri Jul 14 09:52:41 2006
@@ -14,12 +14,12 @@
 
 package org.apache.tapestry.transform;
 
+import static org.apache.tapestry.util.Defense.notBlank;
+
 import java.lang.reflect.Modifier;
 
 import org.apache.tapestry.internal.annotations.SuppressNullCheck;
 
-import static org.apache.tapestry.util.Defense.notBlank;
-
 /**
  * A representation of a method signature, which consists of its name, modifiers (primarily,
  * visibility), return type, parameter types, and declared exception types.
@@ -29,6 +29,7 @@
  * 
  * @author Howard M. Lewis Ship
  */
+@SuppressNullCheck
 public class MethodSignature
 {
 
@@ -48,13 +49,11 @@
 
     /** Convienience for adding a public void method with no parameters or exception types. */
 
-    @SuppressNullCheck
     public MethodSignature(String name)
     {
         this(Modifier.PUBLIC, "void", name, EMPTY_STRINGS, EMPTY_STRINGS);
     }
 
-    @SuppressNullCheck
     public MethodSignature(int modifiers, String type, String name, String[] parameterTypes,
             String[] exceptionTypes)
     {

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/util/CollectionFactory.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/util/CollectionFactory.java?rev=421946&r1=421945&r2=421946&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/util/CollectionFactory.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/util/CollectionFactory.java Fri Jul 14 09:52:41 2006
@@ -85,10 +85,4 @@
     {
         return new CopyOnWriteArrayList<T>();
     }
-
-    /** Easy way to convert an array of like-typed values into a list. */
-    public static <T> List<T> newList(T... values)
-    {
-        return Arrays.asList(values);
-    }
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/util/IdAllocator.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/util/IdAllocator.java?rev=421946&r1=421945&r2=421946&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/util/IdAllocator.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/util/IdAllocator.java Fri Jul 14 09:52:41 2006
@@ -92,8 +92,7 @@
     public IdAllocator clone()
     {
         // Copying the _generatorMap is tricky; multiple keys will point to the same NameGenerator
-        // instance.
-        // We need to clone the NameGenerators, then buld a new map around the clones.
+        // instance. We need to clone the NameGenerators, then build a new map around the clones.
 
         IdentityHashMap<NameGenerator, NameGenerator> transformMap = new IdentityHashMap<NameGenerator, NameGenerator>();
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/internal/util/UtilStrings.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/internal/util/UtilStrings.properties?rev=421946&r1=421945&r2=421946&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/internal/util/UtilStrings.properties (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/internal/util/UtilStrings.properties Fri Jul 14 09:52:41 2006
@@ -12,4 +12,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-unable-to-read-last-modified=Unable to read last modified time stamp of resource {0}: {1}
\ No newline at end of file
+unable-to-read-last-modified=Unable to read last modified time stamp of resource {0}: {1}
+dependency-cycle=Unable to add ''{0}'' as a dependency of ''{1}'', as that forms a dependency cycle (''{1}'' depends on itself via ''{0}''). The dependency has been ignored.
+duplicate-orderer=Could not add object with duplicate id ''{0}''.  The duplicate object has been ignored.
+duplicate-trailer=Could not set ''{0}'' as the last object, because ''{1}'' has already been set.
+duplicate-leader=Could not set ''{0}'' as the first object, because ''{1}'' has already been set.
\ No newline at end of file

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/CatchNullParametersAspectTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/CatchNullParametersAspectTest.java?rev=421946&r1=421945&r2=421946&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/CatchNullParametersAspectTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/CatchNullParametersAspectTest.java Fri Jul 14 09:52:41 2006
@@ -29,7 +29,7 @@
 public class CatchNullParametersAspectTest extends TestBase
 {
     @Test
-    public void publicConstructor()
+    public void public_constructor()
     {
         new NullTarget("not null");
 
@@ -45,7 +45,7 @@
     }
 
     @Test
-    public void privateConstructor()
+    public void private_constructor()
     {
         // This should work
 
@@ -53,13 +53,13 @@
     }
 
     @Test
-    public void equalsAlwaysSuppressed()
+    public void equals_always_suppressed()
     {
         new NullTarget("not null").equals(null);
     }
 
-@Test
-    public void allParametersChecked()
+    @Test
+    public void all_parameters_checked()
     {
         NullTarget t = new NullTarget("not null");
 
@@ -102,12 +102,13 @@
         {
             // Expected.
         }
-       
-        
+
         t.manyParameters(this, "ok", Collections.EMPTY_MAP);
 
-    }    @Test
-    public void publicMethod()
+    }
+
+    @Test
+    public void public_method()
     {
         NullTarget t = new NullTarget();
 
@@ -125,7 +126,7 @@
     }
 
     @Test
-    public void privateMethod()
+    public void private_method()
     {
         NullTarget t = new NullTarget();
 
@@ -133,28 +134,28 @@
     }
 
     @Test
-    public void suppressedConstructor()
+    public void suppressed_constructor()
     {
         // Succeeds:
         new SuppressedNullTarget(null);
     }
 
     @Test
-    public void suppressedPublicMethod()
+    public void suppressed_public_method()
     {
         // Succeeds:
         new SuppressedNullTarget(null).publicMethod(null);
     }
 
     @Test
-    public void directlySuppressedConstructor()
+    public void directly_suppressed_constructor()
     {
         // Succeeds:
         new PartiallySuppressedNullTarget(null);
     }
 
     @Test
-    public void directlySuppressedPublicMethod()
+    public void directly_suppressed_public_method()
     {
         // Succeeds:
         new PartiallySuppressedNullTarget(null).publicMethod(null);

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/InternalUtilityAspectTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/InternalUtilityAspectTest.java?rev=421946&r1=421945&r2=421946&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/InternalUtilityAspectTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/InternalUtilityAspectTest.java Fri Jul 14 09:52:41 2006
@@ -25,7 +25,7 @@
 {
     /** Try to instantiate a utility class to see that it can't be done. */
     @Test
-    public void ensureUtilitiesMayNotBeInstantiated()
+    public void ensure_utilities_may_not_be_instantiated()
     {
         try
         {
@@ -36,7 +36,7 @@
         {
             assertEquals(
                     ex.getMessage(),
-                    "Class org.apache.tapestry.transform.TransformConstants has been marked as a utility class (with the @Utility annotation) and can not be instantiated.");
+                    "Class org.apache.tapestry.transform.TransformConstants has been marked as a utility class (with the @Utility annotation) and may not be instantiated.");
         }
     }
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/SynchronizationAspectTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/SynchronizationAspectTest.java?rev=421946&r1=421945&r2=421946&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/SynchronizationAspectTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/SynchronizationAspectTest.java Fri Jul 14 09:52:41 2006
@@ -39,7 +39,7 @@
     private static final int THREAD_BLOCK_SIZE = 5;
 
     @Test
-    public void readLockThenWriteLock() throws Exception
+    public void read_lock_then_write_lock() throws Exception
     {
         Runnable operation = new Runnable()
         {
@@ -53,7 +53,7 @@
     }
 
     @Test
-    public void readLockInsideWriteLock() throws Exception
+    public void read_lock_inside_write_lock() throws Exception
     {
         Runnable operation = new Runnable()
         {
@@ -68,7 +68,7 @@
     }
 
     @Test(enabled = true)
-    public void writeLockInsideReadLock() throws Exception
+    public void write_lock_inside_read_lock() throws Exception
     {
         Runnable operation = new Runnable()
         {
@@ -84,7 +84,7 @@
     }
 
     @Test(enabled = true)
-    public void indirectionBetweenReadMethodAndWriteMethod() throws Exception
+    public void indirection_between_read_method_and_write_method() throws Exception
     {
         Runnable operation = new Runnable()
         {
@@ -105,7 +105,7 @@
      * more than one object involved.
      */
     @Test
-    public void multipleSynchronizedObjects() throws Exception
+    public void multiple_synchronized_objects() throws Exception
     {
         Runnable operation = new SynchTargetWrapper(_target);
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/BasicServiceCreatorTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/BasicServiceCreatorTest.java?rev=421946&r1=421945&r2=421946&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/BasicServiceCreatorTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/BasicServiceCreatorTest.java Fri Jul 14 09:52:41 2006
@@ -14,6 +14,9 @@
 
 package org.apache.tapestry.internal.ioc;
 
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertSame;
+
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 
@@ -27,9 +30,6 @@
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertSame;
-
 /**
  * @author Howard M. Lewis Ship
  */
@@ -69,7 +69,7 @@
     }
 
     @Test
-    public void noargsMethod()
+    public void noargs_method()
     {
         ServiceDef def = newServiceDef();
         ServiceResources resources = newServiceResources();
@@ -81,13 +81,8 @@
 
         replay();
 
-        ServiceCreator sc = new BasicServiceCreator(def, this, resources);
-
-        verify();
-
-        trainGetBuilderMethod(def, findMethod("build_noargs"));
-
-        replay();
+        ServiceCreator sc = new BasicServiceCreator(def, findMethod("build_noargs"), this,
+                resources);
 
         Object actual = sc.createService();
 
@@ -109,7 +104,7 @@
     }
 
     @Test
-    public void argsMethod()
+    public void method_with_args()
     {
         ServiceDef def = newServiceDef();
         ServiceResources resources = newServiceResources();
@@ -126,11 +121,9 @@
 
         trainForConstructor(def, resources, errorLog, log);
 
-        trainGetBuilderMethod(def, findMethod("build_args"));
-
         replay();
 
-        ServiceCreator sc = new BasicServiceCreator(def, this, resources);
+        ServiceCreator sc = new BasicServiceCreator(def, findMethod("build_args"), this, resources);
 
         Object actual = sc.createService();
 
@@ -140,7 +133,7 @@
     }
 
     @Test
-    public void injectedServiceMethod()
+    public void injected_service_method()
     {
         ServiceDef def = newServiceDef();
         ServiceResources resources = newServiceResources();
@@ -152,13 +145,12 @@
 
         trainForConstructor(def, resources, errorLog, log);
 
-        trainGetBuilderMethod(def, findMethod("build_injected"));
-
         trainGetService(resources, "Foe", FoeService.class, _expectedFoe);
 
         replay();
 
-        ServiceCreator sc = new BasicServiceCreator(def, this, resources);
+        ServiceCreator sc = new BasicServiceCreator(def, findMethod("build_injected"), this,
+                resources);
 
         Object actual = sc.createService();
 
@@ -173,7 +165,7 @@
     }
 
     @Test
-    public void builderMethodReturnsNull()
+    public void builder_method_returns_null()
     {
         ServiceDef def = newServiceDef();
         ServiceResources resources = newServiceResources();
@@ -184,11 +176,10 @@
 
         trainForConstructor(def, resources, errorLog, log);
 
-        trainGetBuilderMethod(def, findMethod("build_noargs"));
-
         replay();
 
-        ServiceCreator sc = new BasicServiceCreator(def, this, resources);
+        ServiceCreator sc = new BasicServiceCreator(def, findMethod("build_noargs"), this,
+                resources);
 
         try
         {
@@ -209,7 +200,7 @@
     }
 
     @Test
-    public void builderMethodFailed()
+    public void builder_method_failed()
     {
         ServiceDef def = newServiceDef();
         ServiceResources resources = newServiceResources();
@@ -220,11 +211,9 @@
 
         trainForConstructor(def, resources, errorLog, log);
 
-        trainGetBuilderMethod(def, findMethod("build_fail"));
-
         replay();
 
-        ServiceCreator sc = new BasicServiceCreator(def, this, resources);
+        ServiceCreator sc = new BasicServiceCreator(def, findMethod("build_fail"), this, resources);
 
         try
         {
@@ -249,7 +238,7 @@
     }
 
     @Test
-    public void autoDependency()
+    public void auto_dependency()
     {
         ServiceDef def = newServiceDef();
         ServiceResources resources = newServiceResources();
@@ -263,13 +252,11 @@
 
         Method method = findMethod("build_auto");
 
-        trainGetBuilderMethod(def, method);
-
         trainGetService(resources, FoeService.class, _expectedFoe);
 
         replay();
 
-        ServiceCreator sc = new BasicServiceCreator(def, this, resources);
+        ServiceCreator sc = new BasicServiceCreator(def, method, this, resources);
 
         Object actual = sc.createService();
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImplTest.java?rev=421946&r1=421945&r2=421946&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImplTest.java Fri Jul 14 09:52:41 2006
@@ -14,6 +14,10 @@
 
 package org.apache.tapestry.internal.ioc;
 
+import static org.apache.tapestry.internal.ioc.IOCMessages.buildMethodConflict;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
 import java.lang.reflect.Method;
 import java.math.BigDecimal;
 import java.util.Set;
@@ -21,22 +25,17 @@
 import org.apache.tapestry.ioc.ErrorLog;
 import org.apache.tapestry.ioc.IOCConstants;
 import org.apache.tapestry.ioc.def.ModuleDef;
-import org.apache.tapestry.ioc.def.ServiceDef;
 import org.apache.tapestry.test.TestBase;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
-import static org.apache.tapestry.internal.ioc.IOCMessages.buildMethodConflict;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-
 /**
  * @author Howard M. Lewis Ship
  */
 public class DefaultModuleDefImplTest extends TestBase
 {
     @Test
-    public void moduleBuilderWithoutId()
+    public void module_builder_without_id()
     {
         ErrorLog log = newErrorLog();
 
@@ -52,7 +51,7 @@
     }
 
     @Test
-    public void moduleBuilderWithId()
+    public void module_builder_with_id()
     {
         ErrorLog log = newErrorLog();
 
@@ -68,7 +67,7 @@
     }
 
     @Test
-    public void simpleModule() throws Exception
+    public void simple_module() throws Exception
     {
         ErrorLog log = newErrorLog();
 
@@ -84,7 +83,7 @@
         assertTrue(ids.contains("ioc.Fred"));
         assertTrue(ids.contains("ioc.Barney"));
 
-        ServiceDef sd = g.getServiceDef("ioc.Fred");
+        ServiceDefImpl sd = (ServiceDefImpl) g.getServiceDef("ioc.Fred");
 
         assertEquals(sd.getServiceId(), "ioc.Fred");
 
@@ -94,7 +93,7 @@
         assertEquals(sd.getServiceLifeycle(), IOCConstants.DEFAULT_LIFECYCLE);
         assertEquals(sd.isPrivate(), false);
 
-        sd = g.getServiceDef("ioc.Barney");
+        sd = (ServiceDefImpl) g.getServiceDef("ioc.Barney");
 
         assertEquals(sd.getServiceId(), "ioc.Barney");
 
@@ -109,12 +108,12 @@
 
     /** Two different methods both claim to build the same service. */
     @Test
-    public void serviceIdConflict() throws Exception
+    public void service_id_conflict() throws Exception
     {
         Method conflictMethod = ServiceIdConflictMethodBuilder.class.getMethod("buildFred");
-        Method expectedMethod = ServiceIdConflictMethodBuilder.class.getMethod(
+        String expectedMethod = ServiceIdConflictMethodBuilder.class.getMethod(
                 "buildFred",
-                Object.class);
+                Object.class).toString();
 
         ErrorLog log = newErrorLog();
 
@@ -131,7 +130,7 @@
         Assert.assertEquals(ids.size(), 1);
         Assert.assertTrue(ids.contains("ioc.Fred"));
 
-        ServiceDef sd = g.getServiceDef("ioc.Fred");
+        ServiceDefImpl sd = (ServiceDefImpl) g.getServiceDef("ioc.Fred");
 
         assertEquals(sd.getServiceId(), "ioc.Fred");
 
@@ -141,7 +140,7 @@
         // parameter count. So the grinder will latch onto the method that takes a parameter,
         // and consider the other method (with no parameters) the conflict.
 
-        assertEquals(sd.getBuilderMethod(), expectedMethod);
+        assertEquals(sd.toString(), expectedMethod.toString());
 
         verify();
     }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ModuleImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ModuleImplTest.java?rev=421946&r1=421945&r2=421946&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ModuleImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ModuleImplTest.java Fri Jul 14 09:52:41 2006
@@ -35,7 +35,7 @@
 
 {
     @Test
-    public void getServiceByIdExists()
+    public void get_service_by_id_exists()
     {
         InternalRegistry registry = newMock(InternalRegistry.class);
         ErrorLog log = newErrorLog();
@@ -63,7 +63,7 @@
     }
 
     @Test
-    public void getServiceByIdPrivate()
+    public void get_service_by_id_private()
     {
         InternalRegistry registry = newMock(InternalRegistry.class);
         ErrorLog log = newErrorLog();
@@ -94,7 +94,7 @@
     }
 
     @Test
-    public void getServiceByIdPrivateWrongModule()
+    public void get_service_by_id_private_wrong_module()
     {
         InternalRegistry registry = newMock(InternalRegistry.class);
         ErrorLog log = newErrorLog();
@@ -121,7 +121,7 @@
     }
 
     @Test
-    public void findServiceIdsForInterface()
+    public void find_service_ids_for_interface()
     {
         InternalRegistry registry = newMock(InternalRegistry.class);
         ErrorLog log = newErrorLog();
@@ -156,7 +156,7 @@
     /** The following tests work better as integration tests. */
 
     @Test
-    public void integrationTests()
+    public void integration_tests()
     {
         Registry registry = buildRegistry();
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/pageload/ComponentTemplateSourceImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/pageload/ComponentTemplateSourceImplTest.java?rev=421946&r1=421945&r2=421946&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/pageload/ComponentTemplateSourceImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/pageload/ComponentTemplateSourceImplTest.java Fri Jul 14 09:52:41 2006
@@ -157,7 +157,7 @@
 
     /** Checks that localization to the same resource works (w/ caching). */
     @Test
-    public void localizationToSame()
+    public void localization_to_same()
     {
         Resource r = newResource("Fred.html");
 
@@ -188,7 +188,7 @@
     }
 
     @Test
-    public void notFound()
+    public void not_found()
     {
         TemplateParser parser = newTemplateParser();
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/parser/TemplateParserImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/parser/TemplateParserImplTest.java?rev=421946&r1=421945&r2=421946&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/parser/TemplateParserImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/parser/TemplateParserImplTest.java Fri Jul 14 09:52:41 2006
@@ -85,7 +85,7 @@
     }
 
     @Test
-    void justHTML()
+    void just_HTML()
     {
         Resource resource = getResource("justHTML.html");
         ComponentTemplate template = _parser.parseTemplate(resource);
@@ -135,7 +135,7 @@
     }
 
     @Test
-    void xmlEntity() throws Exception
+    void xml_entity() throws Exception
     {
         List<TemplateToken> tokens = tokens("xmlEntity.html");
 
@@ -176,7 +176,7 @@
     }
 
     @Test
-    void multilineComment() throws Exception
+    void multiline_comment() throws Exception
     {
         List<TemplateToken> tokens = tokens("multilineComment.html");
 
@@ -207,7 +207,7 @@
     }
 
     @Test
-    void componentWithBody() throws Exception
+    void component_with_body() throws Exception
     {
         List<TemplateToken> tokens = tokens("componentWithBody.html");
 
@@ -223,7 +223,7 @@
     }
 
     @Test
-    void componentWithParameters() throws Exception
+    void component_with_parameters() throws Exception
     {
         List<TemplateToken> tokens = tokens("componentWithParameters.html");
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/UpdateListenerHubImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/UpdateListenerHubImplTest.java?rev=421946&r1=421945&r2=421946&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/UpdateListenerHubImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/UpdateListenerHubImplTest.java Fri Jul 14 09:52:41 2006
@@ -27,7 +27,7 @@
 public class UpdateListenerHubImplTest extends TestBase
 {
     @Test
-    public void addAndInvoke() throws Exception
+    public void add_listener_and_invoke() throws Exception
     {
         UpdateListener listener = newMock(UpdateListener.class);
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/ComponentInstantiatorSourceImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/ComponentInstantiatorSourceImplTest.java?rev=421946&r1=421945&r2=421946&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/ComponentInstantiatorSourceImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/ComponentInstantiatorSourceImplTest.java Fri Jul 14 09:52:41 2006
@@ -70,7 +70,7 @@
     private Registry _registry;
 
     @Test
-    public void controlledPackages() throws Exception
+    public void controlled_packages() throws Exception
     {
 
         ComponentInstantiatorSourceImpl e = new ComponentInstantiatorSourceImpl(_defaultClassLoader);
@@ -98,7 +98,7 @@
 
     /** More of an integration test. */
     @Test
-    public void loadComponentViaService() throws Exception
+    public void load_component_via_service() throws Exception
     {
         ComponentLifecycle target = createComponent(BasicComponent.class);
 
@@ -126,7 +126,7 @@
     }
 
     @Test
-    public void loadSubComponentViaService() throws Exception
+    public void load_sub_component_via_service() throws Exception
     {
         ComponentLifecycle target = createComponent(BasicSubComponent.class);
 
@@ -145,7 +145,7 @@
     }
 
     @Test
-    public void componentClassReload() throws Exception
+    public void component_class_reload() throws Exception
     {
         // Create the class on the fly.
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/InternalClassTransformationImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/InternalClassTransformationImplTest.java?rev=421946&r1=421945&r2=421946&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/InternalClassTransformationImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/InternalClassTransformationImplTest.java Fri Jul 14 09:52:41 2006
@@ -45,6 +45,7 @@
 import org.testng.annotations.Test;
 
 import static java.lang.Thread.currentThread;
+import static java.util.Arrays.asList;
 import static org.apache.tapestry.util.CollectionFactory.newList;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertNotNull;
@@ -177,13 +178,13 @@
 
         String[] unclaimed = ct.findUnclaimedFields();
 
-        assertEquals(Arrays.asList(unclaimed), newList("_field1", "_field4", "_zzfield"));
+        assertEquals(Arrays.asList(unclaimed), asList("_field1", "_field4", "_zzfield"));
 
         ct.claimField("_field4", "Fred");
 
         unclaimed = ct.findUnclaimedFields();
 
-        assertEquals(Arrays.asList(unclaimed), newList("_field1", "_zzfield"));
+        assertEquals(Arrays.asList(unclaimed), asList("_field1", "_zzfield"));
 
         try
         {
@@ -208,7 +209,7 @@
 
         String[] unclaimed = ct.findUnclaimedFields();
 
-        assertEquals(Arrays.asList(unclaimed), newList("_field1", "_field4", "_zzfield"));
+        assertEquals(Arrays.asList(unclaimed), asList("_field1", "_field4", "_zzfield"));
     }
 
     @Test

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/worker/RetainWorkerTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/worker/RetainWorkerTest.java?rev=421946&r1=421945&r2=421946&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/worker/RetainWorkerTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/worker/RetainWorkerTest.java Fri Jul 14 09:52:41 2006
@@ -15,19 +15,18 @@
 package org.apache.tapestry.internal.transform.worker;
 
 import org.apache.tapestry.annotations.Retain;
-import org.apache.tapestry.internal.InternalComponentResources;
+import org.apache.tapestry.internal.test.InternalBaseTestCase;
 import org.apache.tapestry.model.MutableComponentModel;
-import org.apache.tapestry.test.BaseTestCase;
 import org.apache.tapestry.transform.ClassTransformation;
 import org.testng.annotations.Test;
 
 /**
  * @author Howard M. Lewis Ship
  */
-public class RetainWorkerTest extends BaseTestCase
+public class RetainWorkerTest extends InternalBaseTestCase
 {
     @Test
-    public void noFields()
+    public void no_fields()
     {
         ClassTransformation ct = newClassTransformation();
         MutableComponentModel model = newMutableComponentModel();
@@ -63,10 +62,5 @@
         worker.transform(ct, model);
 
         verify();
-    }
-
-    protected final InternalComponentResources newInternalComponentResources()
-    {
-        return newMock(InternalComponentResources.class);
     }
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/worker/UnclaimedFieldWorkerTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/worker/UnclaimedFieldWorkerTest.java?rev=421946&r1=421945&r2=421946&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/worker/UnclaimedFieldWorkerTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/worker/UnclaimedFieldWorkerTest.java Fri Jul 14 09:52:41 2006
@@ -14,25 +14,23 @@
 
 package org.apache.tapestry.internal.transform.worker;
 
+import static org.apache.tapestry.transform.TransformConstants.CONTAINING_PAGE_DID_DETACH_SIGNATURE;
+import static org.apache.tapestry.transform.TransformConstants.CONTAINING_PAGE_DID_LOAD_SIGNATURE;
+
 import java.lang.reflect.Modifier;
 
-import org.apache.tapestry.internal.InternalComponentResources;
+import org.apache.tapestry.internal.test.InternalBaseTestCase;
 import org.apache.tapestry.model.MutableComponentModel;
-import org.apache.tapestry.runtime.ComponentLifecycle;
-import org.apache.tapestry.test.BaseTestCase;
 import org.apache.tapestry.transform.ClassTransformation;
 import org.testng.annotations.Test;
 
-import static org.apache.tapestry.transform.TransformConstants.CONTAINING_PAGE_DID_DETACH_SIGNATURE;
-import static org.apache.tapestry.transform.TransformConstants.CONTAINING_PAGE_DID_LOAD_SIGNATURE;
-
 /**
  * @author Howard M. Lewis Ship
  */
-public class UnclaimedFieldWorkerTest extends BaseTestCase
+public class UnclaimedFieldWorkerTest extends InternalBaseTestCase
 {
     @Test
-    public void noFields()
+    public void no_fields()
     {
         ClassTransformation ct = newClassTransformation();
         MutableComponentModel model = newMutableComponentModel();
@@ -69,10 +67,4 @@
 
         verify();
     }
-
-    protected final InternalComponentResources newInternalComponentResources()
-    {
-        return newMock(InternalComponentResources.class);
-    }
-
 }

Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/util/OrdererTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/util/OrdererTest.java?rev=421946&view=auto
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/util/OrdererTest.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/util/OrdererTest.java Fri Jul 14 09:52:41 2006
@@ -0,0 +1,313 @@
+// 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.
+
+package org.apache.tapestry.internal.util;
+
+import static org.testng.Assert.assertEquals;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.tapestry.internal.test.InternalBaseTestCase;
+import org.apache.tapestry.ioc.ErrorLog;
+import org.apache.tapestry.ioc.Orderable;
+import org.testng.annotations.Test;
+
+/**
+ * @author Howard M. Lewis Ship
+ */
+public class OrdererTest extends InternalBaseTestCase
+{
+    @Test
+    public void no_dependencies()
+    {
+        ErrorLog log = newErrorLog();
+
+        replay();
+
+        Orderer<String> o = new Orderer<String>(log);
+
+        o.add("fred", "FRED");
+        o.add("barney", "BARNEY");
+        o.add("wilma", "WILMA");
+        o.add("betty", "BETTY");
+
+        List<String> ordered = o.getOrdered();
+
+        assertEquals(ordered, Arrays.asList("FRED", "BARNEY", "WILMA", "BETTY"));
+
+        verify();
+    }
+
+    @Test
+    public void nulls_not_included_in_result()
+    {
+        ErrorLog log = newErrorLog();
+
+        replay();
+
+        Orderer<String> o = new Orderer<String>(log);
+
+        o.add("fred", "FRED");
+        o.add("barney", "BARNEY");
+        o.add("zippo", null);
+        o.add("wilma", "WILMA");
+        o.add("groucho", null);
+        o.add("betty", "BETTY");
+
+        List<String> ordered = o.getOrdered();
+
+        assertEquals(ordered, Arrays.asList("FRED", "BARNEY", "WILMA", "BETTY"));
+
+        verify();
+    }
+
+    @Test
+    public void duplicate_id()
+    {
+        ErrorLog log = newErrorLog();
+
+        replay();
+
+        Orderer<String> o = new Orderer<String>(log);
+
+        o.add("fred", "FRED");
+        o.add("barney", "BARNEY");
+        o.add("wilma", "WILMA");
+
+        verify();
+
+        log.warn("Could not add object with duplicate id 'fred'.  "
+                + "The duplicate object has been ignored.", null);
+
+        replay();
+
+        o.add("fred", "FRED2");
+
+        verify();
+
+        replay();
+
+        o.add("betty", "BETTY");
+
+        List<String> ordered = o.getOrdered();
+
+        assertEquals(ordered, Arrays.asList("FRED", "BARNEY", "WILMA", "BETTY"));
+
+        verify();
+    }
+
+    @Test
+    public void leader()
+    {
+        ErrorLog log = newErrorLog();
+
+        replay();
+
+        Orderer<String> o = new Orderer<String>(log);
+
+        o.add("fred", "FRED");
+        o.add("barney", null, "*", "BARNEY");
+        o.add("wilma", "WILMA");
+        o.add("betty", "BETTY");
+
+        List<String> ordered = o.getOrdered();
+
+        assertEquals(ordered, Arrays.asList("BARNEY", "FRED", "WILMA", "BETTY"));
+
+        verify();
+    }
+
+    @Test
+    public void trailer()
+    {
+        ErrorLog log = newErrorLog();
+
+        replay();
+
+        Orderer<String> o = new Orderer<String>(log);
+
+        o.add("fred", "FRED");
+        o.add("barney", "*", null, "BARNEY");
+        o.add("wilma", "WILMA");
+        o.add("betty", "BETTY");
+
+        List<String> ordered = o.getOrdered();
+
+        assertEquals(ordered, Arrays.asList("FRED", "WILMA", "BETTY", "BARNEY"));
+
+        verify();
+    }
+
+    @Test
+    public void duplicate_trailer()
+    {
+        ErrorLog log = newErrorLog();
+
+        log.warn("Could not set 'wilma' as the last object, "
+                + "because 'barney' has already been set.", null);
+
+        replay();
+
+        Orderer<String> o = new Orderer<String>(log);
+
+        o.add("fred", "FRED");
+        o.add("barney", "*", null, "BARNEY");
+        o.add("wilma", "*", null, "WILMA");
+        o.add("betty", "BETTY");
+
+        List<String> ordered = o.getOrdered();
+
+        assertEquals(ordered, Arrays.asList("FRED", "WILMA", "BETTY", "BARNEY"));
+
+        verify();
+    }
+
+    @Test
+    public void duplicate_leader()
+    {
+        ErrorLog log = newErrorLog();
+
+        log.warn("Could not set 'wilma' as the first object, "
+                + "because 'barney' has already been set.", null);
+
+        replay();
+
+        Orderer<String> o = new Orderer<String>(log);
+
+        o.add("fred", "FRED");
+        o.add("barney", null, "*", "BARNEY");
+        o.add("wilma", null, "*", "WILMA");
+        o.add("betty", "BETTY");
+
+        List<String> ordered = o.getOrdered();
+
+        assertEquals(ordered, Arrays.asList("BARNEY", "FRED", "WILMA", "BETTY"));
+
+        verify();
+    }
+
+    @Test
+    public void prereqs()
+    {
+        ErrorLog log = newErrorLog();
+
+        replay();
+
+        Orderer<String> o = new Orderer<String>(log);
+
+        o.add("fred", "wilma", null, "FRED");
+        o.add("barney", "fred,betty", null, "BARNEY");
+        o.add("wilma", "WILMA");
+        o.add("betty", "BETTY");
+
+        List<String> ordered = o.getOrdered();
+
+        assertEquals(ordered, Arrays.asList("WILMA", "FRED", "BETTY", "BARNEY"));
+
+        verify();
+    }
+
+    @Test
+    public void pre_and_post_reqs()
+    {
+        ErrorLog log = newErrorLog();
+
+        replay();
+
+        Orderer<String> o = new Orderer<String>(log);
+
+        o.add("fred", "wilma", null, "FRED");
+        o.add("barney", "fred,betty", null, "BARNEY");
+        o.add("wilma", "WILMA");
+        o.add("betty", null, "wilma", "BETTY");
+
+        List<String> ordered = o.getOrdered();
+
+        assertEquals(ordered, Arrays.asList("BETTY", "WILMA", "FRED", "BARNEY"));
+
+        verify();
+    }
+
+    @Test
+    public void dependency_cycle()
+    {
+        ErrorLog log = newErrorLog();
+
+        log.warn("Unable to add 'barney' as a dependency of 'betty', as that forms a "
+                + "dependency cycle ('betty' depends on itself via 'barney'). "
+                + "The dependency has been ignored.", null);
+
+        replay();
+
+        Orderer<String> o = new Orderer<String>(log);
+
+        o.add("fred", "wilma", null, "FRED");
+        o.add("barney", "fred,betty", null, "BARNEY");
+        o.add("wilma", "WILMA");
+        o.add("betty", "barney", "wilma", "BETTY");
+
+        List<String> ordered = o.getOrdered();
+
+        assertEquals(ordered, Arrays.asList("BETTY", "WILMA", "FRED", "BARNEY"));
+
+        verify();
+    }
+
+    @Test
+    public void toString_Orderable()
+    {
+        Orderable<String> simple = new Orderable<String>("simple", "SIMPLE");
+
+        assertEquals(simple.toString(), "Orderable[simple SIMPLE]");
+
+        Orderable<String> complex = new Orderable<String>("complex", "pre", "post", "COMPLEX");
+
+        assertEquals(complex.toString(), "Orderable[complex pre:pre post:post COMPLEX]");
+    }
+
+    @Test
+    public void toString_DependencyNode()
+    {
+        ErrorLog log = newErrorLog();
+
+        replay();
+
+        DependencyNode<String> node1 = new DependencyNode<String>(log, new Orderable("node1",
+                "NODE1"));
+
+        assertEquals(node1.toString(), "[node1]");
+
+        DependencyNode<String> node2 = new DependencyNode<String>(log, new Orderable("node2",
+                "NODE2"));
+
+        DependencyNode<String> node3 = new DependencyNode<String>(log, new Orderable("node3",
+                "NODE3"));
+
+        DependencyNode<String> node4 = new DependencyNode<String>(log, new Orderable("node4",
+                "NODE4"));
+
+        DependencyNode<String> node5 = new DependencyNode<String>(log, new Orderable("node5",
+                "NODE5"));
+
+        node2.addDependency(node1);
+        node1.addDependency(node3);
+        node1.addDependency(node4);
+        node5.addDependency(node1);
+
+        assertEquals(node5.toString(), "[node5: [node1: [node3], [node4]]]");
+
+        verify();
+    }
+}