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/08/21 03:49:49 UTC

svn commit: r433119 - in /tapestry/tapestry5/tapestry-core/trunk/src: main/java/org/apache/tapestry/dom/ main/java/org/apache/tapestry/test/ test/conf/ test/java/org/apache/tapestry/internal/aspects/ test/java/org/apache/tapestry/internal/ioc/ test/jav...

Author: hlship
Date: Sun Aug 20 18:49:49 2006
New Revision: 433119

URL: http://svn.apache.org/viewvc?rev=433119&view=rev
Log:
Recode some test case classes to support running tests in parallel.

Added:
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceBuilderMethodFixture.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceDecoratorFixture.java
Modified:
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Node.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/test/TestBase.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/conf/testng.xml
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/ConcurrenceAspectTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceBuilderMethodInvokerTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceDecoratorImplTest.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/transform/InternalClassTransformationImplTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/services/PropertyShadowBuilderImplTest.java

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Node.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Node.java?rev=433119&r1=433118&r2=433119&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Node.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Node.java Sun Aug 20 18:49:49 2006
@@ -73,7 +73,7 @@
     }
 
     /**
-     * Invokes {@link #toString()}, collecting output in a string, which is returned.
+     * Invokes {@link #toXML(PrintWriter)}, collecting output in a string, which is returned.
      */
     @Override
     public String toString()

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=433119&r1=433118&r2=433119&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 Sun Aug 20 18:49:49 2006
@@ -257,9 +257,14 @@
                 methodName));
     }
 
+    protected final Method findMethod(Object subject, String methodName)
+    {
+        return findMethod(subject.getClass(), methodName);
+    }
+
     protected final Method findMethod(String methodName)
     {
-        return findMethod(getClass(), methodName);
+        return findMethod(this, methodName);
     }
 
     protected final Configuration newConfiguration()

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/TestBase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/TestBase.java?rev=433119&r1=433118&r2=433119&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/TestBase.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/TestBase.java Sun Aug 20 18:49:49 2006
@@ -19,9 +19,7 @@
 import org.easymock.EasyMock;
 import org.easymock.IMocksControl;
 import org.testng.Assert;
-import org.testng.annotations.Configuration;
-
-import static org.easymock.EasyMock.expectLastCall;
+import org.testng.annotations.AfterMethod;
 
 /**
  * Manages a set of EasyMock mock objects. Used as a base class for test cases.
@@ -35,18 +33,32 @@
  */
 public class TestBase extends Assert
 {
-    private IMocksControl _control;
+    private class ThreadLocalControl extends ThreadLocal<IMocksControl>
+    {
+        @Override
+        protected IMocksControl initialValue()
+        {
+            return EasyMock.createStrictControl();
+        }
+    }
+
+    private final ThreadLocalControl _localControl = new ThreadLocalControl();
+
+    /**
+     * Returns the {@link IMocksControl} for this thread.
+     */
+    protected final IMocksControl getMocksControl()
+    {
+        return _localControl.get();
+    }
 
     /**
      * Discards any mock objects created during the test.
      */
-    @Configuration(afterTestMethod = true, alwaysRun = true)
-    protected final void tearDown()
+    @AfterMethod(alwaysRun = true)
+    public final void discardMockControl()
     {
-        // TestNG reuses the same class instance across all tests methods within that class, so if
-        // we don't clear out the mocks, they will tend to accumulate (which isn't the end of the
-        // world, but it's nice to save unneccessary cycles even inside a test case).
-        _control = null;
+        _localControl.remove();
     }
 
     /**
@@ -61,10 +73,7 @@
      */
     protected final <T> T newMock(Class<T> mockClass)
     {
-        if (_control == null)
-            _control = EasyMock.createStrictControl();
-
-        return _control.createMock(mockClass);
+        return getMocksControl().createMock(mockClass);
     }
 
     /**
@@ -72,7 +81,7 @@
      */
     protected final void replay()
     {
-        _control.replay();
+        getMocksControl().replay();
     }
 
     /**
@@ -80,8 +89,8 @@
      */
     protected final void verify()
     {
-        _control.verify();
-        _control.reset();
+        getMocksControl().verify();
+        getMocksControl().reset();
     }
 
     /**
@@ -90,10 +99,11 @@
      * @param returnValue
      *            value to be returned from the method call
      */
+    @SuppressWarnings("unchecked")
     @SuppressNullCheck
     protected final void setReturnValue(Object returnValue)
     {
-        expectLastCall().andReturn(returnValue);
+        getMocksControl().andReturn(returnValue);
     }
 
     /**
@@ -104,7 +114,7 @@
      */
     protected final void setThrowable(Throwable throwable)
     {
-        expectLastCall().andThrow(throwable);
+        getMocksControl().andThrow(throwable);
     }
 
     /**

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?rev=433119&r1=433118&r2=433119&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/conf/testng.xml (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/conf/testng.xml Sun Aug 20 18:49:49 2006
@@ -15,21 +15,21 @@
    limitations under the License.
 -->
 
-<suite name="Tapestry 5">
-  <test verbose="2" name="General" annotations="1.5">
+<suite name="Tapestry 5" parallel="true" thread-count="5" annotations="1.5" verbose="2">
+  <test name="General">
     <packages>
       <package name="org.apache.tapestry.internal.aspects"/>
       <package name="org.apache.tapestry.internal.ioc"/>
       <package name="org.apache.tapestry.internal.ioc.services"/>
       <package name="org.apache.tapestry.internal.pageload"/>
       <package name="org.apache.tapestry.internal.parser"/>
-      <package name="org.apache.tapestry.internal.services"/>      
-      <package name="org.apache.tapestry.internal.transform"/>      
-      <package name="org.apache.tapestry.internal.transform.pages"/>      
+      <package name="org.apache.tapestry.internal.services"/>
+      <package name="org.apache.tapestry.internal.transform"/>
+      <package name="org.apache.tapestry.internal.transform.pages"/>
       <package name="org.apache.tapestry.internal.transform.worker"/>
       <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"/>
+      <package name="org.apache.tapestry.ioc.services"/>
       <package name="org.apache.tapestry.transform"/>
       <package name="org.apache.tapestry.util"/>
     </packages>

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/ConcurrenceAspectTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/ConcurrenceAspectTest.java?rev=433119&r1=433118&r2=433119&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/ConcurrenceAspectTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/ConcurrenceAspectTest.java Sun Aug 20 18:49:49 2006
@@ -17,17 +17,18 @@
 import java.util.List;
 
 import org.apache.tapestry.test.TestBase;
-import org.testng.annotations.Configuration;
+import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
 import static org.apache.tapestry.util.CollectionFactory.newList;
 
 /** @author Howard M. Lewis Ship */
+@Test(sequential = true)
 public class ConcurrenceAspectTest extends TestBase
 {
     private ConcurrentTarget _target;
 
-    @Configuration(beforeTestClass = true)
+    @BeforeClass
     public void createTarget()
     {
         _target = new ConcurrentTarget();

Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceBuilderMethodFixture.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceBuilderMethodFixture.java?rev=433119&view=auto
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceBuilderMethodFixture.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceBuilderMethodFixture.java Sun Aug 20 18:49:49 2006
@@ -0,0 +1,110 @@
+// 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.ioc;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.tapestry.ioc.ServiceResources;
+import org.apache.tapestry.ioc.annotations.InjectService;
+import org.testng.Assert;
+
+/**
+ * Used by {@link org.apache.tapestry.internal.ioc.ServiceBuilderMethodInvokerTest}.
+ * 
+ * @author Howard M. Lewis Ship
+ */
+public class ServiceBuilderMethodFixture extends Assert
+{
+    FieService _fie;
+
+    String _expectedServiceId;
+
+    ServiceResources _expectedServiceResources;
+
+    Class _expectedServiceInterface;
+
+    Log _expectedLog;
+
+    FoeService _expectedFoe;
+
+    Object _expectedConfiguration;
+
+    public FieService buildWithUnorderedConfiguration(Collection<Runnable> configuration)
+    {
+        assertSame(configuration, _expectedConfiguration);
+
+        return _fie;
+    }
+
+    public FieService buildWithOrderedConfiguration(List<Runnable> configuration)
+    {
+        assertSame(configuration, _expectedConfiguration);
+
+        return _fie;
+    }
+
+    public void methodWithParameterizedList(List<Runnable> list)
+    {
+    }
+
+    public void methodWithList(List list)
+    {
+    }
+
+    public void methodWithWildcardList(List<? super ArrayList> list)
+    {
+
+    }
+
+    public FieService build_noargs()
+    {
+        return _fie;
+    }
+
+    public FieService build_injected(@InjectService("Foe")
+    FoeService foe)
+    {
+        assertSame(_expectedFoe, foe);
+
+        return _fie;
+    }
+
+    public FieService build_auto(FoeService foe)
+    {
+        assertSame(_expectedFoe, foe);
+
+        return _fie;
+    }
+
+    public FieService build_fail()
+    {
+        throw new RuntimeException("Method failed.");
+    }
+
+    public FieService build_args(String serviceId, ServiceResources resources,
+            Class serviceInterface, Log log)
+    {
+        assertEquals(serviceId, _expectedServiceId);
+        assertSame(resources, _expectedServiceResources);
+        assertSame(serviceInterface, _expectedServiceInterface);
+        assertSame(log, _expectedLog);
+
+        return _fie;
+    }
+
+}

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceBuilderMethodInvokerTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceBuilderMethodInvokerTest.java?rev=433119&r1=433118&r2=433119&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceBuilderMethodInvokerTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceBuilderMethodInvokerTest.java Sun Aug 20 18:49:49 2006
@@ -16,7 +16,6 @@
 
 import java.lang.reflect.Method;
 import java.lang.reflect.Type;
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
@@ -24,8 +23,6 @@
 import org.apache.tapestry.internal.test.InternalBaseTestCase;
 import org.apache.tapestry.ioc.ObjectCreator;
 import org.apache.tapestry.ioc.ServiceBuilderResources;
-import org.apache.tapestry.ioc.ServiceResources;
-import org.apache.tapestry.ioc.annotations.InjectService;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
@@ -38,40 +35,29 @@
 {
     private static final String SERVICE_ID = "ioc.Fie";
 
-    private FieService _fie;
-
-    private String _expectedServiceId;
-
-    private ServiceResources _expectedServiceResources;
-
-    private Class _expectedServiceInterface;
-
-    private Log _expectedLog;
-
-    private FoeService _expectedFoe;
-
-    private Object _expectedConfiguration;
-
     @Test
     public void noargs_method()
     {
+        ServiceBuilderMethodFixture fixture = new ServiceBuilderMethodFixture();
         ServiceBuilderResources resources = newServiceCreatorResources();
         Log log = newLog();
-        _fie = newFieService();
+
+        fixture._fie = newFieService();
 
         trainForConstructor(resources, log);
 
-        trainGetModuleBuilder(resources, this);
+        trainGetModuleBuilder(resources, fixture);
 
         trainIsDebugEnabled(log, false);
 
         replay();
 
-        ObjectCreator sc = new ServiceBuilderMethodInvoker(findMethod("build_noargs"), resources);
+        ObjectCreator sc = new ServiceBuilderMethodInvoker(findMethod(fixture, "build_noargs"),
+                resources);
 
         Object actual = sc.createObject();
 
-        assertSame(actual, _fie);
+        assertSame(actual, fixture._fie);
 
         verify();
     }
@@ -88,21 +74,22 @@
     @Test
     public void method_with_args()
     {
-        Method method = findMethod("build_args");
+        ServiceBuilderMethodFixture fixture = new ServiceBuilderMethodFixture();
+        Method method = findMethod(fixture, "build_args");
         ServiceBuilderResources resources = newServiceCreatorResources();
 
         Log log = newLog();
 
-        _expectedServiceId = SERVICE_ID;
-        _expectedServiceInterface = FieService.class;
-        _expectedServiceResources = resources;
-        _expectedLog = log;
+        fixture._expectedServiceId = SERVICE_ID;
+        fixture._expectedServiceInterface = FieService.class;
+        fixture._expectedServiceResources = resources;
+        fixture._expectedLog = log;
 
-        _fie = newFieService();
+        fixture._fie = newFieService();
 
         trainForConstructor(resources, log);
 
-        trainGetModuleBuilder(resources, this);
+        trainGetModuleBuilder(resources, fixture);
 
         trainIsDebugEnabled(log, true);
 
@@ -114,7 +101,7 @@
 
         Object actual = sc.createObject();
 
-        assertSame(actual, _fie);
+        assertSame(actual, fixture._fie);
 
         verify();
     }
@@ -122,27 +109,29 @@
     @Test
     public void injected_service_method()
     {
+        ServiceBuilderMethodFixture fixture = new ServiceBuilderMethodFixture();
         ServiceBuilderResources resources = newServiceCreatorResources();
         Log log = newLog();
 
-        _fie = newFieService();
-        _expectedFoe = newFoe();
+        fixture._fie = newFieService();
+        fixture._expectedFoe = newFoe();
 
         trainForConstructor(resources, log);
 
-        trainGetModuleBuilder(resources, this);
+        trainGetModuleBuilder(resources, fixture);
 
         trainIsDebugEnabled(log, false);
 
-        trainGetService(resources, "Foe", FoeService.class, _expectedFoe);
+        trainGetService(resources, "Foe", FoeService.class, fixture._expectedFoe);
 
         replay();
 
-        ObjectCreator sc = new ServiceBuilderMethodInvoker(findMethod("build_injected"), resources);
+        ObjectCreator sc = new ServiceBuilderMethodInvoker(findMethod(fixture, "build_injected"),
+                resources);
 
         Object actual = sc.createObject();
 
-        assertSame(actual, _fie);
+        assertSame(actual, fixture._fie);
 
         verify();
     }
@@ -150,29 +139,31 @@
     @Test
     public void injected_ordered_collection()
     {
+        ServiceBuilderMethodFixture fixture = new ServiceBuilderMethodFixture();
         ServiceBuilderResources resources = newServiceCreatorResources();
         Log log = newLog();
 
-        _fie = newFieService();
-        _expectedConfiguration = newMock(List.class);
+        fixture._fie = newFieService();
+        fixture._expectedConfiguration = newMock(List.class);
 
         trainForConstructor(resources, log);
 
-        trainGetModuleBuilder(resources, this);
+        trainGetModuleBuilder(resources, fixture);
 
         trainIsDebugEnabled(log, false);
 
         resources.getOrderedConfiguration(Runnable.class);
-        setReturnValue(_expectedConfiguration);
+        setReturnValue(fixture._expectedConfiguration);
 
         replay();
 
-        ObjectCreator sc = new ServiceBuilderMethodInvoker(
-                findMethod("buildWithOrderedConfiguration"), resources);
+        ObjectCreator sc = new ServiceBuilderMethodInvoker(findMethod(
+                fixture,
+                "buildWithOrderedConfiguration"), resources);
 
         Object actual = sc.createObject();
 
-        assertSame(actual, _fie);
+        assertSame(actual, fixture._fie);
 
         verify();
 
@@ -181,47 +172,35 @@
     @Test
     public void injected_unordered_collection()
     {
+        ServiceBuilderMethodFixture fixture = new ServiceBuilderMethodFixture();
         ServiceBuilderResources resources = newServiceCreatorResources();
         Log log = newLog();
 
-        _fie = newFieService();
-        _expectedConfiguration = newMock(Collection.class);
+        fixture._fie = newFieService();
+        fixture._expectedConfiguration = newMock(Collection.class);
 
         trainForConstructor(resources, log);
 
-        trainGetModuleBuilder(resources, this);
+        trainGetModuleBuilder(resources, fixture);
 
         trainIsDebugEnabled(log, false);
 
         resources.getUnorderedConfiguration(Runnable.class);
-        setReturnValue(_expectedConfiguration);
+        setReturnValue(fixture._expectedConfiguration);
 
         replay();
 
-        ObjectCreator sc = new ServiceBuilderMethodInvoker(
-                findMethod("buildWithUnorderedConfiguration"), resources);
+        ObjectCreator sc = new ServiceBuilderMethodInvoker(findMethod(
+                fixture,
+                "buildWithUnorderedConfiguration"), resources);
 
         Object actual = sc.createObject();
 
-        assertSame(actual, _fie);
+        assertSame(actual, fixture._fie);
 
         verify();
     }
 
-    public FieService buildWithUnorderedConfiguration(Collection<Runnable> configuration)
-    {
-        assertSame(configuration, _expectedConfiguration);
-
-        return _fie;
-    }
-
-    public FieService buildWithOrderedConfiguration(List<Runnable> configuration)
-    {
-        assertSame(configuration, _expectedConfiguration);
-
-        return _fie;
-    }
-
     private FoeService newFoe()
     {
         return newFoeService();
@@ -230,20 +209,20 @@
     @Test
     public void builder_method_returns_null()
     {
+        ServiceBuilderMethodFixture fixture = new ServiceBuilderMethodFixture();
         ServiceBuilderResources resources = newServiceCreatorResources();
         Log log = newLog();
 
-        _fie = null;
-
         trainForConstructor(resources, log);
 
-        trainGetModuleBuilder(resources, this);
+        trainGetModuleBuilder(resources, fixture);
 
         trainIsDebugEnabled(log, false);
 
         replay();
 
-        ObjectCreator sc = new ServiceBuilderMethodInvoker(findMethod("build_noargs"), resources);
+        ObjectCreator sc = new ServiceBuilderMethodInvoker(findMethod(fixture, "build_noargs"),
+                resources);
 
         try
         {
@@ -252,8 +231,9 @@
         }
         catch (RuntimeException ex)
         {
-            Assert.assertEquals(ex.getMessage(), "Builder method " + getClass().getName()
-                    + ".build_noargs() " + "(for service 'ioc.Fie') returned null.");
+            Assert.assertEquals(ex.getMessage(), "Builder method "
+                    + ServiceBuilderMethodFixture.class.getName() + ".build_noargs() "
+                    + "(for service 'ioc.Fie') returned null.");
         }
 
         verify();
@@ -262,20 +242,20 @@
     @Test
     public void builder_method_failed()
     {
+        ServiceBuilderMethodFixture fixture = new ServiceBuilderMethodFixture();
         ServiceBuilderResources resources = newServiceCreatorResources();
         Log log = newLog();
 
-        _fie = null;
-
         trainForConstructor(resources, log);
 
-        trainGetModuleBuilder(resources, this);
+        trainGetModuleBuilder(resources, fixture);
 
         trainIsDebugEnabled(log, false);
 
         replay();
 
-        ObjectCreator sc = new ServiceBuilderMethodInvoker(findMethod("build_fail"), resources);
+        ObjectCreator sc = new ServiceBuilderMethodInvoker(findMethod(fixture, "build_fail"),
+                resources);
 
         try
         {
@@ -285,7 +265,7 @@
         catch (RuntimeException ex)
         {
             assertEquals(ex.getMessage(), "Error invoking service builder method "
-                    + getClass().getName() + ".build_fail() "
+                    + ServiceBuilderMethodFixture.class.getName() + ".build_fail() "
                     + "(for service 'ioc.Fie'): Method failed.");
 
             Throwable cause = ex.getCause();
@@ -299,21 +279,22 @@
     @Test
     public void auto_dependency()
     {
-        Method method = findMethod("build_auto");
+        ServiceBuilderMethodFixture fixture = new ServiceBuilderMethodFixture();
+        Method method = findMethod(fixture, "build_auto");
 
         ServiceBuilderResources resources = newServiceCreatorResources();
         Log log = newLog();
 
-        _fie = newFieService();
-        _expectedFoe = newFoeService();
+        fixture._fie = newFieService();
+        fixture._expectedFoe = newFoeService();
 
         trainForConstructor(resources, log);
 
-        trainGetModuleBuilder(resources, this);
+        trainGetModuleBuilder(resources, fixture);
 
         trainIsDebugEnabled(log, false);
 
-        trainGetService(resources, FoeService.class, _expectedFoe);
+        trainGetService(resources, FoeService.class, fixture._expectedFoe);
 
         replay();
 
@@ -323,7 +304,7 @@
 
         verify();
 
-        assertSame(actual, _fie);
+        assertSame(actual, fixture._fie);
     }
 
     protected final void trainGetModuleBuilder(ServiceBuilderResources resources,
@@ -336,7 +317,7 @@
     @Test
     public void parameterized_type_of_generic_parameter()
     {
-        Method m = findMethod("methodWithParameterizedList");
+        Method m = findMethod(ServiceBuilderMethodFixture.class, "methodWithParameterizedList");
 
         assertEquals(m.getParameterTypes()[0], List.class);
         Type type = m.getGenericParameterTypes()[0];
@@ -345,14 +326,10 @@
         assertEquals(findParameterizedTypeFromGenericType(type), Runnable.class);
     }
 
-    public void methodWithParameterizedList(List<Runnable> list)
-    {
-    }
-
     @Test
     public void parameterized_type_of_nongeneric_parameter()
     {
-        Method m = findMethod("methodWithList");
+        Method m = findMethod(ServiceBuilderMethodFixture.class, "methodWithList");
 
         assertEquals(m.getParameterTypes()[0], List.class);
         Type type = m.getGenericParameterTypes()[0];
@@ -361,15 +338,10 @@
         assertEquals(findParameterizedTypeFromGenericType(type), Object.class);
     }
 
-    public void methodWithList(List list)
-    {
-
-    }
-
     @Test
     public void parameterize_type_for_non_supported_type()
     {
-        Method m = findMethod("methodWithWildcardList");
+        Method m = findMethod(ServiceBuilderMethodFixture.class, "methodWithWildcardList");
 
         assertEquals(m.getParameterTypes()[0], List.class);
         Type type = m.getGenericParameterTypes()[0];
@@ -385,11 +357,6 @@
         }
     }
 
-    public void methodWithWildcardList(List<? super ArrayList> list)
-    {
-
-    }
-
     private FoeService newFoeService()
     {
         return newMock(FoeService.class);
@@ -398,42 +365,6 @@
     private FieService newFieService()
     {
         return newMock(FieService.class);
-    }
-
-    public FieService build_noargs()
-    {
-        return _fie;
-    }
-
-    public FieService build_injected(@InjectService("Foe")
-    FoeService foe)
-    {
-        assertSame(_expectedFoe, foe);
-
-        return _fie;
-    }
-
-    public FieService build_auto(FoeService foe)
-    {
-        assertSame(_expectedFoe, foe);
-
-        return _fie;
-    }
-
-    public FieService build_fail()
-    {
-        throw new RuntimeException("Method failed.");
-    }
-
-    public FieService build_args(String serviceId, ServiceResources resources,
-            Class serviceInterface, Log log)
-    {
-        assertEquals(serviceId, _expectedServiceId);
-        assertSame(resources, _expectedServiceResources);
-        assertSame(serviceInterface, _expectedServiceInterface);
-        assertSame(log, _expectedLog);
-
-        return _fie;
     }
 
 }

Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceDecoratorFixture.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceDecoratorFixture.java?rev=433119&view=auto
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceDecoratorFixture.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceDecoratorFixture.java Sun Aug 20 18:49:49 2006
@@ -0,0 +1,56 @@
+// 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.ioc;
+
+import org.testng.Assert;
+
+/**
+ * Used by {@link org.apache.tapestry.internal.ioc.ServiceDecoratorImplTest}.
+ * 
+ * @author Howard M. Lewis Ship
+ */
+public class ServiceDecoratorFixture extends Assert
+{
+    Object _expectedDelegate;
+
+    Object _interceptorToReturn;
+
+    RuntimeException _exception;
+
+    public <T> T decoratorReturnsInterceptor(Class<T> serviceInterface, T delegate)
+    {
+        assertSame(serviceInterface, FieService.class);
+        assertSame(delegate, _expectedDelegate);
+
+        return serviceInterface.cast(_interceptorToReturn);
+    }
+
+    public Object decoratorUntyped(Object delegate)
+    {
+        assertSame(delegate, _expectedDelegate);
+
+        return _interceptorToReturn;
+    }
+
+    public Object decoratorThrowsException(Object delegate)
+    {
+        throw _exception;
+    }
+
+    public Object decorateReturnNull(Object delegate)
+    {
+        return null;
+    }
+}

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceDecoratorImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceDecoratorImplTest.java?rev=433119&r1=433118&r2=433119&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceDecoratorImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceDecoratorImplTest.java Sun Aug 20 18:49:49 2006
@@ -28,12 +28,6 @@
 {
     private static final String SERVICE_ID = "ioc.Fie";
 
-    private Object _expectedDelegate;
-
-    private Object _interceptorToReturn;
-
-    private RuntimeException _exception;
-
     /**
      * Also, test logging of decorator method invocation.
      * 
@@ -42,12 +36,13 @@
     @Test
     public void decorator_returns_interceptor() throws Exception
     {
-        Method m = getClass().getMethod("decoratorReturnsInterceptor", Class.class, Object.class);
+        ServiceDecoratorFixture fixture = new ServiceDecoratorFixture();
+        Method m = findMethod(fixture, "decoratorReturnsInterceptor");
 
         ServiceResources resources = newServiceResources();
         Log log = newLog();
-        _expectedDelegate = newFieService();
-        _interceptorToReturn = newFieService();
+        fixture._expectedDelegate = newFieService();
+        fixture._interceptorToReturn = newFieService();
 
         trainForConstructor(resources, log);
 
@@ -60,33 +55,19 @@
         // Check that the delegate gets passed in; check that the return value of the
         // decorator method is the return value of the ServiceDecorator.
 
-        ServiceDecoratorImpl decorator = new ServiceDecoratorImpl(m, this, resources);
+        ServiceDecoratorImpl decorator = new ServiceDecoratorImpl(m, fixture, resources);
 
-        Object interceptor = decorator.createInterceptor(_expectedDelegate);
+        Object interceptor = decorator.createInterceptor(fixture._expectedDelegate);
 
-        assertSame(interceptor, _interceptorToReturn);
+        assertSame(interceptor, fixture._interceptorToReturn);
 
         verify();
     }
 
-    public <T> T decoratorReturnsInterceptor(Class<T> serviceInterface, T delegate)
-    {
-        assertSame(serviceInterface, FieService.class);
-        assertSame(delegate, _expectedDelegate);
-
-        return serviceInterface.cast(_interceptorToReturn);
-    }
-
-    public Object decoratorUntyped(Object delegate)
-    {
-        assertSame(delegate, _expectedDelegate);
-
-        return _interceptorToReturn;
-    }
-
     @Test
     public void decorator_returns_null_interceptor() throws Exception
     {
+        ServiceDecoratorFixture fixture = new ServiceDecoratorFixture();
         ServiceResources resources = newServiceResources();
         Log log = newLog();
         Object delegate = newFieService();
@@ -97,9 +78,9 @@
 
         replay();
 
-        Method m = getClass().getMethod("decorateReturnNull", Object.class);
+        Method m = findMethod(fixture, "decorateReturnNull");
 
-        ServiceDecoratorImpl decorator = new ServiceDecoratorImpl(m, this, resources);
+        ServiceDecoratorImpl decorator = new ServiceDecoratorImpl(m, fixture, resources);
 
         Object interceptor = decorator.createInterceptor(delegate);
 
@@ -111,12 +92,13 @@
     @Test
     public void decorator_returns_incorrect_type() throws Exception
     {
+        ServiceDecoratorFixture fixture = new ServiceDecoratorFixture();
         ServiceResources resources = newServiceResources();
         Log log = newLog();
-        _expectedDelegate = newFieService();
-        _interceptorToReturn = newMock(FoeService.class);
+        fixture._expectedDelegate = newFieService();
+        fixture._interceptorToReturn = newMock(FoeService.class);
 
-        Method m = getClass().getMethod("decoratorUntyped", Object.class);
+        Method m = findMethod(fixture, "decoratorUntyped");
 
         trainForConstructor(resources, log);
 
@@ -125,14 +107,14 @@
         log.warn(IOCMessages.decoratorReturnedWrongType(
                 m,
                 SERVICE_ID,
-                _interceptorToReturn,
+                fixture._interceptorToReturn,
                 FieService.class), null);
 
         replay();
 
-        ServiceDecoratorImpl decorator = new ServiceDecoratorImpl(m, this, resources);
+        ServiceDecoratorImpl decorator = new ServiceDecoratorImpl(m, fixture, resources);
 
-        Object interceptor = decorator.createInterceptor(_expectedDelegate);
+        Object interceptor = decorator.createInterceptor(fixture._expectedDelegate);
 
         assertNull(interceptor);
 
@@ -142,10 +124,11 @@
     @Test
     public void decorator_method_throws_exception() throws Exception
     {
+        ServiceDecoratorFixture fixture = new ServiceDecoratorFixture();
         ServiceResources resources = newServiceResources();
         Log log = newLog();
         Object delegate = newFieService();
-        _exception = new RuntimeException("Ouch!");
+        fixture._exception = new RuntimeException("Ouch!");
 
         trainForConstructor(resources, log);
 
@@ -153,9 +136,9 @@
 
         replay();
 
-        Method m = getClass().getMethod("decoratorThrowsException", Object.class);
+        Method m = findMethod(fixture, "decoratorThrowsException");
 
-        ServiceDecoratorImpl decorator = new ServiceDecoratorImpl(m, this, resources);
+        ServiceDecoratorImpl decorator = new ServiceDecoratorImpl(m, fixture, resources);
 
         try
         {
@@ -169,25 +152,15 @@
 
             Throwable cause = ex.getCause();
 
-            assertSame(cause, _exception);
+            assertSame(cause, fixture._exception);
         }
 
         verify();
     }
 
-    public Object decoratorThrowsException(Object delegate)
-    {
-        throw _exception;
-    }
-
     private FieService newFieService()
     {
         return newMock(FieService.class);
-    }
-
-    public Object decorateReturnNull(Object delegate)
-    {
-        return null;
     }
 
     private void trainForConstructor(ServiceResources resources, Log log)

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=433119&r1=433118&r2=433119&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 Sun Aug 20 18:49:49 2006
@@ -21,15 +21,18 @@
 import org.apache.tapestry.Resource;
 import org.apache.tapestry.internal.ClasspathResource;
 import org.apache.tapestry.test.BaseTestCase;
-import org.testng.annotations.Configuration;
+import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
 /**
  * This is used to test the template parser ... and in some cases, the underlying behavior of the
  * SAX APIs.
+ * <p>
+ * The tests are run sequentially, as they all share a single template parser.
  * 
  * @author Howard M. Lewis Ship
  */
+@Test(sequential = true)
 public class TemplateParserImplTest extends BaseTestCase
 {
     private TemplateParser _parser;
@@ -38,7 +41,7 @@
      * What's nice is that we get to set up a single parser for all the test methods to share, which
      * will actually do a very good job of simulating how a parser is used in production.
      */
-    @Configuration(beforeTestClass = true)
+    @BeforeClass
     public void setupParser()
     {
         _parser = new TemplateParserImpl();

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=433119&r1=433118&r2=433119&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 Sun Aug 20 18:49:49 2006
@@ -41,15 +41,19 @@
 import org.apache.tapestry.runtime.ResourceAware;
 import org.apache.tapestry.test.BaseTestCase;
 import org.apache.tapestry.transform.ClassTransformation;
-import org.testng.annotations.Configuration;
+import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import static java.lang.Thread.currentThread;
 import static java.util.Arrays.asList;
 
 /**
+ * <p>
+ * The tests share a number of resources, and so are run sequentially.
+ * 
  * @author Howard M. Lewis Ship
  */
+@Test(sequential = true)
 public class InternalClassTransformationImplTest extends BaseTestCase
 {
     private ClassPool _classPool;
@@ -60,7 +64,7 @@
      * We need a new ClassPool for each individual test, since many of the tests will end up
      * modifying one or more CtClass instances.
      */
-    @Configuration(beforeTestMethod = true)
+    @BeforeMethod
     public void setupClassPool()
     {
         _classPool = new ClassPool();

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/services/PropertyShadowBuilderImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/services/PropertyShadowBuilderImplTest.java?rev=433119&r1=433118&r2=433119&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/services/PropertyShadowBuilderImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/services/PropertyShadowBuilderImplTest.java Sun Aug 20 18:49:49 2006
@@ -18,7 +18,7 @@
 
 import org.apache.tapestry.internal.test.InternalBaseTestCase;
 import org.apache.tapestry.ioc.Registry;
-import org.testng.annotations.Configuration;
+import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
 /**
@@ -30,8 +30,8 @@
 
     private final String CLASS_NAME = getClass().getName();
 
-    @Configuration(beforeTestClass = true)
-    public void setBuilder()
+    @BeforeClass
+    public void setupBuilder()
     {
         Registry registry = buildRegistry();