Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java?rev=911931&r1=911930&r2=911931&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
 Fri Feb 19 18:54:27 2010
@@ -14,16 +14,17 @@
 
 package org.apache.tapestry5.integration.app1.pages;
 
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
 import org.apache.tapestry5.ComponentResources;
 import org.apache.tapestry5.Link;
 import org.apache.tapestry5.annotations.InjectPage;
+import org.apache.tapestry5.annotations.Property;
 import org.apache.tapestry5.ioc.annotations.Inject;
 import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
 
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
 /**
  * Have to start somewhere!
  */
@@ -469,6 +470,7 @@
         Collections.sort(ITEMS);
     }
 
+    @Property
     private Item item;
 
     @InjectPage
@@ -482,16 +484,6 @@
         return ITEMS;
     }
 
-    public Item getItem()
-    {
-        return item;
-    }
-
-    public void setItem(Item item)
-    {
-        this.item = item;
-    }
-
     Object onActionFromSecurePage()
     {
         return securePage.initialize("Triggered from Index");

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app2/services/LocaleAppModule.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app2/services/LocaleAppModule.java?rev=911931&r1=911930&r2=911931&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app2/services/LocaleAppModule.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app2/services/LocaleAppModule.java
 Fri Feb 19 18:54:27 2010
@@ -14,15 +14,8 @@
 
 package org.apache.tapestry5.integration.app2.services;
 
-import org.apache.tapestry5.integration.app2.FortyTwo;
-import org.apache.tapestry5.integration.app2.PlusOne;
-import org.apache.tapestry5.ioc.MappedConfiguration;
-import org.apache.tapestry5.ioc.OrderedConfiguration;
-import org.apache.tapestry5.model.MutableComponentModel;
-import org.apache.tapestry5.services.ClassTransformation;
-import org.apache.tapestry5.services.ComponentClassTransformWorker;
-import org.apache.tapestry5.services.TransformMethodSignature;
 import org.apache.tapestry5.SymbolConstants;
+import org.apache.tapestry5.ioc.MappedConfiguration;
 
 public class LocaleAppModule
 {
@@ -30,35 +23,4 @@
     {
         configuration.add(SymbolConstants.SUPPORTED_LOCALES, "en,fr,de");
     }
-
-    public static void contributeComponentClassTransformWorker(
-            OrderedConfiguration<ComponentClassTransformWorker> configuration)
-    {
-        configuration.add("FortyTwo", new FortyTwoWorker());
-        configuration.add("PlusOne", new PlusOneWorker());
-    }
-
-    private static final class FortyTwoWorker implements 
ComponentClassTransformWorker
-    {
-
-        public void transform(ClassTransformation transformation, 
MutableComponentModel model)
-        {
-            for (TransformMethodSignature sig : 
transformation.findMethodsWithAnnotation(FortyTwo.class))
-            {
-                transformation.prefixMethod(sig, "return 42;");
-            }
-        }
-
-    }
-
-    private static final class PlusOneWorker implements 
ComponentClassTransformWorker
-    {
-        public void transform(ClassTransformation transformation, 
MutableComponentModel model)
-        {
-            for (TransformMethodSignature method : 
transformation.findMethodsWithAnnotation(PlusOne.class))
-            {
-                transformation.extendExistingMethod(method, "return $_ + 1;");
-            }
-        }
-    }
 }

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentInstantiatorSourceImplTest.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentInstantiatorSourceImplTest.java?rev=911931&r1=911930&r2=911931&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentInstantiatorSourceImplTest.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentInstantiatorSourceImplTest.java
 Fri Feb 19 18:54:27 2010
@@ -99,56 +99,7 @@
 
         verify();
     }
-
-    /**
-     * More of an integration test.
-     */
-    @Test
-    public void load_component_via_service() throws Exception
-    {
-        Component target = createComponent(BasicComponent.class);
-
-        // Should not be an instance, since it is loaded by a different class 
loader.
-        assertFalse(BasicComponent.class.isInstance(target));
-
-        access.set(target, "value", "some default value");
-        assertEquals(access.get(target, "value"), "some default value");
-
-        access.set(target, "retainedValue", "some retained value");
-        assertEquals(access.get(target, "retainedValue"), "some retained 
value");
-
-        // Setting a property value before pageDidLoad will cause that value
-        // to be the default when the page detaches.
-
-        target.containingPageDidLoad();
-
-        access.set(target, "value", "some transient value");
-        assertEquals(access.get(target, "value"), "some transient value");
-
-        target.containingPageDidDetach();
-
-        assertEquals(access.get(target, "value"), "some default value");
-        assertEquals(access.get(target, "retainedValue"), "some retained 
value");
-    }
-
-    @Test
-    public void load_sub_component_via_service() throws Exception
-    {
-        Component target = createComponent(BasicSubComponent.class);
-
-        target.containingPageDidLoad();
-
-        access.set(target, "value", "base class");
-        assertEquals(access.get(target, "value"), "base class");
-
-        access.set(target, "intValue", 33);
-        assertEquals(access.get(target, "intValue"), 33);
-
-        target.containingPageDidDetach();
-
-        assertNull(access.get(target, "value"));
-        assertEquals(access.get(target, "intValue"), 0);
-    }
+ 
 
     /**
      * This allows tests the exists() method.
@@ -166,6 +117,8 @@
 
         assertTrue(source.exists(SYNTH_COMPONENT_CLASSNAME));
 
+        getMocksControl().resetToNice();
+        
         Named named = (Named) createComponent(SYNTH_COMPONENT_CLASSNAME);
 
         assertEquals(named.getName(), "Original");

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/InternalClassTransformationImplTest.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/InternalClassTransformationImplTest.java?rev=911931&r1=911930&r2=911931&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/InternalClassTransformationImplTest.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/InternalClassTransformationImplTest.java
 Fri Feb 19 18:54:27 2010
@@ -127,8 +127,7 @@
         classSource = new CtClassSourceImpl(classFactoryClassPool, loader);
     }
 
-    private Object transform(Class componentClass, 
ComponentClassTransformWorker worker)
-            throws Exception
+    private Object transform(Class componentClass, 
ComponentClassTransformWorker worker) throws Exception
     {
         InternalComponentResources resources = 
mockInternalComponentResources();
 
@@ -139,8 +138,8 @@
 
         replay();
 
-        InternalClassTransformation ct = new 
InternalClassTransformationImpl(classFactory,
-                targetObjectCtClass, new 
ComponentClassCacheImpl(classFactory), model, classSource);
+        InternalClassTransformation ct = new 
InternalClassTransformationImpl(classFactory, targetObjectCtClass,
+                new ComponentClassCacheImpl(classFactory, null), model, 
classSource);
 
         worker.transform(ct, model);
 
@@ -253,8 +252,7 @@
         }
         catch (RuntimeException ex)
         {
-            assertEquals(
-                    ex.getMessage(),
+            assertEquals(ex.getMessage(),
                     "Class 
org.apache.tapestry5.internal.transform.pages.ParentClass does not contain a 
field named 'unknownField'.");
         }
 
@@ -445,8 +443,7 @@
 
         replay();
 
-        ClassTransformation ct = 
createClassTransformation(ChildClassInheritsAnnotation.class,
-                logger);
+        ClassTransformation ct = 
createClassTransformation(ChildClassInheritsAnnotation.class, logger);
 
         InheritedAnnotation ia = ct.getAnnotation(InheritedAnnotation.class);
 
@@ -465,8 +462,7 @@
 
         replay();
 
-        ClassTransformation ct = 
createClassTransformation(ChildClassInheritsAnnotation.class,
-                logger);
+        ClassTransformation ct = 
createClassTransformation(ChildClassInheritsAnnotation.class, logger);
 
         Meta meta = ct.getAnnotation(Meta.class);
 
@@ -503,8 +499,7 @@
     }
 
     @Test
-    public void 
ensure_javassist_does_not_show_interface_methods_on_abstract_class()
-            throws Exception
+    public void 
ensure_javassist_does_not_show_interface_methods_on_abstract_class() throws 
Exception
     {
         CtClass ctClass = findCtClass(AbstractFoo.class);
 
@@ -524,8 +519,7 @@
     }
 
     @Test
-    public void 
ensure_javassist_does_not_show_extended_interface_methods_on_interface()
-            throws Exception
+    public void 
ensure_javassist_does_not_show_extended_interface_methods_on_interface() throws 
Exception
     {
         CtClass ctClass = findCtClass(FooBarInterface.class);
 
@@ -548,23 +542,20 @@
             {
                 transformation.addImplementedInterface(Runnable.class);
 
-                TransformMethodSignature targetMethodSignature = new 
TransformMethodSignature(
-                        "publicVoidNoArgs");
-                TransformMethod pvna = 
transformation.getMethod(targetMethodSignature);
+                TransformMethodSignature targetMethodSignature = new 
TransformMethodSignature("publicVoidNoArgs");
+                TransformMethod pvna = 
transformation.getOrCreateMethod(targetMethodSignature);
 
                 final MethodAccess pvnaAccess = pvna.getAccess();
 
-                transformation.getMethod(RUN).addAdvice(new 
ComponentMethodAdvice()
+                transformation.getOrCreateMethod(RUN).addAdvice(new 
ComponentMethodAdvice()
                 {
                     public void advise(ComponentMethodInvocation invocation)
                     {
                         invocation.proceed();
 
-                        MethodInvocationResult invocationResult = 
pvnaAccess.invoke(invocation
-                                .getInstance());
+                        MethodInvocationResult invocationResult = 
pvnaAccess.invoke(invocation.getInstance());
 
-                        assertFalse(invocationResult.isFail(),
-                                "fail should be false, no checked exception 
thrown");
+                        assertFalse(invocationResult.isFail(), "fail should be 
false, no checked exception thrown");
                     }
                 });
             }
@@ -586,24 +577,22 @@
             {
                 transformation.addImplementedInterface(Runnable.class);
 
-                TransformMethodSignature targetMethodSignature = new 
TransformMethodSignature(
-                        Modifier.PUBLIC, "void", "publicVoidThrowsException", 
null, new String[]
+                TransformMethodSignature targetMethodSignature = new 
TransformMethodSignature(Modifier.PUBLIC, "void",
+                        "publicVoidThrowsException", null, new String[]
                         { SQLException.class.getName() });
-                TransformMethod targetMethod = 
transformation.getMethod(targetMethodSignature);
+                TransformMethod targetMethod = 
transformation.getOrCreateMethod(targetMethodSignature);
 
                 final MethodAccess targetAccess = targetMethod.getAccess();
 
-                transformation.getMethod(RUN).addAdvice(new 
ComponentMethodAdvice()
+                transformation.getOrCreateMethod(RUN).addAdvice(new 
ComponentMethodAdvice()
                 {
                     public void advise(ComponentMethodInvocation invocation)
                     {
                         invocation.proceed();
 
-                        MethodInvocationResult invocationResult = 
targetAccess.invoke(invocation
-                                .getInstance());
+                        MethodInvocationResult invocationResult = 
targetAccess.invoke(invocation.getInstance());
 
-                        assertTrue(invocationResult.isFail(),
-                                "fail should be true; checked exception 
thrown");
+                        assertTrue(invocationResult.isFail(), "fail should be 
true; checked exception thrown");
 
                         SQLException ex = 
invocationResult.getThrown(SQLException.class);
 
@@ -635,18 +624,17 @@
             {
                 transformation.addImplementedInterface(ProcessInteger.class);
 
-                TransformMethod incrementer = transformation
-                        .getMethod(new 
TransformMethodSignature(Modifier.PUBLIC, "int",
-                                "incrementer", new String[]
-                                { "int" }, null));
+                TransformMethod incrementer = 
transformation.getOrCreateMethod(new TransformMethodSignature(
+                        Modifier.PUBLIC, "int", "incrementer", new String[]
+                        { "int" }, null));
 
                 final MethodAccess incrementerAccess = incrementer.getAccess();
 
-                TransformMethodSignature operateSig = new 
TransformMethodSignature(Modifier.PUBLIC,
-                        "int", "operate", new String[]
+                TransformMethodSignature operateSig = new 
TransformMethodSignature(Modifier.PUBLIC, "int", "operate",
+                        new String[]
                         { "int" }, null);
 
-                TransformMethod operate = transformation.getMethod(operateSig);
+                TransformMethod operate = 
transformation.getOrCreateMethod(operateSig);
 
                 operate.addAdvice(new ComponentMethodAdvice()
                 {
@@ -661,8 +649,7 @@
 
                         Integer parameter = (Integer) 
invocation.getParameter(0);
 
-                        MethodInvocationResult result = 
incrementerAccess.invoke(invocation
-                                .getInstance(), parameter);
+                        MethodInvocationResult result = 
incrementerAccess.invoke(invocation.getInstance(), parameter);
 
                         invocation.overrideResult(result.getReturnValue());
                     }
@@ -691,18 +678,17 @@
             {
                 
transformation.addImplementedInterface(ProcessStringAndInteger.class);
 
-                TransformMethod targetMethod = transformation
-                        .getMethod(new 
TransformMethodSignature(Modifier.PRIVATE,
-                                "java.lang.String", "privateMethod", new 
String[]
-                                { "java.lang.String", "int" }, null));
+                TransformMethod targetMethod = 
transformation.getOrCreateMethod(new TransformMethodSignature(
+                        Modifier.PRIVATE, "java.lang.String", "privateMethod", 
new String[]
+                        { "java.lang.String", "int" }, null));
 
                 final MethodAccess targetMethodAccess = 
targetMethod.getAccess();
 
-                TransformMethodSignature processSig = new 
TransformMethodSignature(Modifier.PUBLIC,
-                        "java.lang.String", "process", new String[]
+                TransformMethodSignature processSig = new 
TransformMethodSignature(Modifier.PUBLIC, "java.lang.String",
+                        "process", new String[]
                         { "java.lang.String", "int" }, null);
 
-                TransformMethod process = transformation.getMethod(processSig);
+                TransformMethod process = 
transformation.getOrCreateMethod(processSig);
 
                 process.addAdvice(new ComponentMethodAdvice()
                 {
@@ -711,9 +697,8 @@
                         // Don't even bother with proceed() this time, which 
is OK (but
                         // somewhat rare).
 
-                        MethodInvocationResult result = 
targetMethodAccess.invoke(invocation
-                                .getInstance(), invocation.getParameter(0), 
invocation
-                                .getParameter(1));
+                        MethodInvocationResult result = 
targetMethodAccess.invoke(invocation.getInstance(), invocation
+                                .getParameter(0), invocation.getParameter(1));
 
                         invocation.overrideResult(result.getReturnValue());
                     }
@@ -740,8 +725,8 @@
 
         replay();
 
-        InternalClassTransformation ct = new 
InternalClassTransformationImpl(classFactory,
-                targetObjectCtClass, null, model, null);
+        InternalClassTransformation ct = new 
InternalClassTransformationImpl(classFactory, targetObjectCtClass, null,
+                model, null);
 
         // Default behavior is to add an injected field for the 
InternalComponentResources object,
         // so we'll just check that.
@@ -758,111 +743,6 @@
     }
 
     @Test
-    public void add_injected_field_from_parent_transformation() throws 
Exception
-    {
-        final String value = "from the parent";
-
-        InternalComponentResources resources = 
mockInternalComponentResources();
-
-        CtClass targetObjectCtClass = findCtClass(TargetObject.class);
-
-        Logger logger = mockLogger();
-        MutableComponentModel model = mockMutableComponentModel();
-
-        train_getLogger(model, logger);
-
-        replay();
-
-        InternalClassTransformation ct = new 
InternalClassTransformationImpl(classFactory,
-                targetObjectCtClass, null, model, null);
-
-        String parentFieldName = ct.addInjectedField(String.class, "_value", 
value);
-
-        // Default behavior is to add an injected field for the 
InternalComponentResources object,
-        // so we'll just check that.
-
-        ct.finish();
-
-        // Now lets work on the subclass
-
-        CtClass subclassCtClass = findCtClass(TargetObjectSubclass.class);
-
-        ct = ct.createChildTransformation(subclassCtClass, model);
-
-        String subclassFieldName = ct.addInjectedField(String.class, 
"_childValue", value);
-
-        // This is what proves it is cached.
-
-        assertEquals(subclassFieldName, parentFieldName);
-
-        // This proves the the field is protected and can be used in 
subclasses.
-
-        ct.addMethod(new TransformMethodSignature(Modifier.PUBLIC, 
"java.lang.String", "getValue",
-                null, null), "return " + subclassFieldName + ";");
-
-        ct.finish();
-
-        Instantiator instantiator = ct.createInstantiator();
-
-        Object instance = instantiator.newInstance(resources);
-
-        Object actual = access.get(instance, "value");
-
-        assertSame(actual, value);
-
-        verify();
-    }
-
-    @Test
-    public void add_interface_to_class() throws Exception
-    {
-        InternalComponentResources resources = 
mockInternalComponentResources();
-
-        CtClass targetObjectCtClass = findCtClass(TargetObject.class);
-
-        Logger logger = mockLogger();
-        MutableComponentModel model = mockMutableComponentModel(logger);
-
-        replay();
-
-        InternalClassTransformation ct = new 
InternalClassTransformationImpl(classFactory,
-                targetObjectCtClass, null, model, null);
-
-        ct.addImplementedInterface(FooInterface.class);
-        ct.addImplementedInterface(GetterMethodsInterface.class);
-
-        ct.finish();
-
-        Class transformed = toClass(targetObjectCtClass);
-
-        Class[] interfaces = transformed.getInterfaces();
-
-        assertEquals(interfaces, new Class[]
-        { Component.class, FooInterface.class, GetterMethodsInterface.class });
-
-        Object target = ct.createInstantiator().newInstance(resources);
-
-        FooInterface asFoo = (FooInterface) target;
-
-        asFoo.foo();
-
-        GetterMethodsInterface getters = (GetterMethodsInterface) target;
-
-        assertEquals(getters.getBoolean(), false);
-        assertEquals(getters.getByte(), (byte) 0);
-        assertEquals(getters.getShort(), (short) 0);
-        assertEquals(getters.getInt(), 0);
-        assertEquals(getters.getLong(), 0l);
-        assertEquals(getters.getFloat(), 0.0f);
-        assertEquals(getters.getDouble(), 0.0d);
-        assertNull(getters.getString());
-        assertNull(getters.getObjectArray());
-        assertNull(getters.getIntArray());
-
-        verify();
-    }
-
-    @Test
     public void make_field_read_only() throws Exception
     {
         InternalComponentResources resources = 
mockInternalComponentResources();
@@ -874,8 +754,8 @@
 
         CtClass targetObjectCtClass = findCtClass(ReadOnlyBean.class);
 
-        InternalClassTransformation ct = new 
InternalClassTransformationImpl(classFactory,
-                targetObjectCtClass, null, model, null);
+        InternalClassTransformation ct = new 
InternalClassTransformationImpl(classFactory, targetObjectCtClass, null,
+                model, null);
 
         ct.makeReadOnly("_value");
 
@@ -900,52 +780,6 @@
     }
 
     @Test
-    public void removed_fields_should_not_show_up_as_unclaimed() throws 
Exception
-    {
-        Logger logger = mockLogger();
-        MutableComponentModel model = mockMutableComponentModel(logger);
-
-        replay();
-
-        CtClass targetObjectCtClass = findCtClass(RemoveFieldBean.class);
-
-        InternalClassTransformation ct = new 
InternalClassTransformationImpl(null,
-                targetObjectCtClass, null, model, null);
-
-        ct.removeField("_barney");
-
-        assertEquals(ct.findUnclaimedFields(), asList("_fred"));
-
-        verify();
-    }
-
-    @Test
-    public void add_to_constructor() throws Exception
-    {
-        InternalComponentResources resources = 
mockInternalComponentResources();
-
-        Logger logger = mockLogger();
-        MutableComponentModel model = mockMutableComponentModel(logger);
-
-        replay();
-
-        CtClass targetObjectCtClass = findCtClass(ReadOnlyBean.class);
-
-        InternalClassTransformation ct = new 
InternalClassTransformationImpl(classFactory,
-                targetObjectCtClass, null, model, null);
-
-        ct.extendConstructor("_value = \"from constructor\";");
-
-        ct.finish();
-
-        Object target = instantiate(ReadOnlyBean.class, ct, resources);
-
-        assertEquals(access.get(target, "value"), "from constructor");
-
-        verify();
-    }
-
-    @Test
     public void inject_field() throws Exception
     {
         InternalComponentResources resources = 
mockInternalComponentResources();
@@ -957,8 +791,8 @@
 
         CtClass targetObjectCtClass = findCtClass(ReadOnlyBean.class);
 
-        InternalClassTransformation ct = new 
InternalClassTransformationImpl(classFactory,
-                targetObjectCtClass, null, model, null);
+        InternalClassTransformation ct = new 
InternalClassTransformationImpl(classFactory, targetObjectCtClass, null,
+                model, null);
 
         ct.injectField("_value", "Tapestry");
 
@@ -1000,8 +834,8 @@
 
         CtClass targetObjectCtClass = findCtClass(FieldAccessBean.class);
 
-        InternalClassTransformation ct = new 
InternalClassTransformationImpl(classFactory,
-                targetObjectCtClass, null, model, null);
+        InternalClassTransformation ct = new 
InternalClassTransformationImpl(classFactory, targetObjectCtClass, null,
+                model, null);
 
         replaceAccessToField(ct, "foo");
         replaceAccessToField(ct, "bar");
@@ -1052,21 +886,19 @@
         String fieldName = "_" + baseName;
         String readMethodName = "_read_" + baseName;
 
-        TransformMethodSignature readMethodSignature = new 
TransformMethodSignature(
-                Modifier.PRIVATE, STRING_CLASS_NAME, readMethodName, null, 
null);
+        TransformMethodSignature readMethodSignature = new 
TransformMethodSignature(Modifier.PRIVATE,
+                STRING_CLASS_NAME, readMethodName, null, null);
 
-        ct.addMethod(readMethodSignature, String.format("throw new 
RuntimeException(\"read %s\");",
-                baseName));
+        ct.addNewMethod(readMethodSignature, String.format("throw new 
RuntimeException(\"read %s\");", baseName));
 
         ct.replaceReadAccess(fieldName, readMethodName);
 
         String writeMethodName = "_write_" + baseName;
 
-        TransformMethodSignature writeMethodSignature = new 
TransformMethodSignature(
-                Modifier.PRIVATE, "void", writeMethodName, new String[]
+        TransformMethodSignature writeMethodSignature = new 
TransformMethodSignature(Modifier.PRIVATE, "void",
+                writeMethodName, new String[]
                 { STRING_CLASS_NAME }, null);
-        ct.addMethod(writeMethodSignature, String.format(
-                "throw new RuntimeException(\"write %s\");", baseName));
+        ct.addNewMethod(writeMethodSignature, String.format("throw new 
RuntimeException(\"write %s\");", baseName));
 
         ct.replaceWriteAccess(fieldName, writeMethodName);
     }
@@ -1181,8 +1013,8 @@
         }
         catch (RuntimeException ex)
         {
-            assertMessageContains(ex, "Class " + VisibilityBean.class.getName()
-                    + " contains field(s)", "_$myPackagePrivate", 
"_$myProtected", "_$myPublic");
+            assertMessageContains(ex, "Class " + 
VisibilityBean.class.getName() + " contains field(s)",
+                    "_$myPackagePrivate", "_$myProtected", "_$myPublic");
         }
 
         verify();
@@ -1197,8 +1029,7 @@
 
         ClassTransformation ct = 
createClassTransformation(EventHandlerTarget.class, logger);
 
-        OnEvent annotation = ct.getMethodAnnotation(new 
TransformMethodSignature("handler"),
-                OnEvent.class);
+        OnEvent annotation = ct.getMethodAnnotation(new 
TransformMethodSignature("handler"), OnEvent.class);
 
         // Check that the attributes of the annotation match the expectation.
 
@@ -1207,99 +1038,8 @@
 
         verify();
     }
-
-    @Test
-    public void find_annotation_in_unknown_method() throws Exception
-    {
-        Logger logger = mockLogger();
-
-        replay();
-
-        ClassTransformation ct = createClassTransformation(ParentClass.class, 
logger);
-
-        try
-        {
-            ct.getMethodAnnotation(new TransformMethodSignature("foo"), 
OnEvent.class);
-            unreachable();
-        }
-        catch (IllegalArgumentException ex)
-        {
-            assertEquals(
-                    ex.getMessage(),
-                    "Class 
org.apache.tapestry5.internal.transform.pages.ParentClass does not declare 
method 'public void foo()'.");
-        }
-
-        verify();
-    }
-
-    @Test
-    public void prefix_method() throws Exception
-    {
-        Logger logger = mockLogger();
-        TransformMethodSignature sig = new 
TransformMethodSignature(Modifier.PUBLIC, "int",
-                "getParentField", null, null);
-
-        replay();
-
-        InternalClassTransformation ct = 
createClassTransformation(ParentClass.class, logger);
-        ct.prefixMethod(sig, "return 42;");
-
-        String desc = ct.toString();
-        assertTrue(desc.contains("prefix"));
-        assertTrue(desc.contains("getParentField"));
-
-        // fail if frozen
-        ct.finish();
-        try
-        {
-            ct.prefixMethod(sig, "return 0;");
-            unreachable();
-        }
-        catch (IllegalStateException e)
-        {
-        }
-
-        verify();
-    }
-
-    @Test
-    public void fields_in_prefixed_methods_are_transformed() throws Exception
-    {
-        Logger logger = mockLogger();
-        TransformMethodSignature sig = new 
TransformMethodSignature(Modifier.PUBLIC, "int",
-                "getTargetValue", null, null);
-        Runnable runnable = mockRunnable();
-
-        runnable.run();
-
-        replay();
-
-        InternalClassTransformation ct = 
createClassTransformation(MethodPrefixTarget.class, logger);
-
-        String name = ct.addInjectedField(Runnable.class, "runnable", 
runnable);
-
-        // Transform the field.
-
-        TransformMethodSignature reader = new 
TransformMethodSignature(Modifier.PRIVATE, "int",
-                "read_target_value", null, null);
-
-        ct.addMethod(reader, "return 66;");
-
-        ct.replaceReadAccess("_targetField", "read_target_value");
-
-        ct.prefixMethod(sig, name + ".run();");
-
-        ct.finish();
-
-        Object target = instantiate(MethodPrefixTarget.class, ct, null);
-
-        // 66 reflects the change to the field.
-
-        assertEquals(access.get(target, "targetValue"), 66);
-
-        verify();
-    }
-
+   
+ 
     private Component instantiate(Class<?> expectedClass, 
InternalClassTransformation ct,
             InternalComponentResources resources) throws Exception
     {
@@ -1308,102 +1048,8 @@
         return ins.newInstance(resources);
     }
 
-    @Test
-    public void extend_existing_method_fields_are_transformed() throws 
Exception
-    {
-        Logger logger = mockLogger();
-        TransformMethodSignature sig = new 
TransformMethodSignature(Modifier.PUBLIC, "int",
-                "getTargetValue", null, null);
-        Runnable runnable = mockRunnable();
-
-        runnable.run();
-
-        replay();
-
-        InternalClassTransformation ct = 
createClassTransformation(MethodPrefixTarget.class, logger);
-
-        String name = ct.addInjectedField(Runnable.class, "runnable", 
runnable);
-
-        // Transform the field.
-
-        TransformMethodSignature reader = new 
TransformMethodSignature(Modifier.PRIVATE, "int",
-                "read_target_value", null, null);
-
-        ct.addMethod(reader, "return 66;");
-
-        ct.replaceReadAccess("_targetField", "read_target_value");
-
-        BodyBuilder builder = new BodyBuilder();
-        builder.begin();
-        builder.addln("%s.run();", name);
-        builder.addln("return $_ + 1;");
-        builder.end();
-
-        ct.extendExistingMethod(sig, builder.toString());
-
-        ct.finish();
-
-        Object target = instantiate(MethodPrefixTarget.class, ct, null);
-
-        // 66 reflects the change to the field, +1 reflects the extension of 
the method.
-
-        assertEquals(access.get(target, "targetValue"), 67);
-
-        verify();
-    }
-
-    @Test
-    public void invalid_code() throws Exception
-    {
-        Logger logger = mockLogger();
-        TransformMethodSignature sig = new 
TransformMethodSignature(Modifier.PUBLIC, "int",
-                "getParentField", null, null);
-
-        replay();
-
-        InternalClassTransformation ct = 
createClassTransformation(ParentClass.class, logger);
-
-        try
-        {
-            ct.prefixMethod(sig, "return supercalafragalistic;");
-            unreachable();
-        }
-        catch (MethodCompileException ex)
-        {
-
-        }
-
-        verify();
-    }
-
-    @Test
-    public void remove_field() throws Exception
-    {
-        Logger logger = mockLogger();
-        MutableComponentModel model = mockMutableComponentModel(logger);
-
-        replay();
-
-        CtClass targetObjectCtClass = findCtClass(FieldRemoval.class);
-
-        InternalClassTransformation ct = new 
InternalClassTransformationImpl(classFactory,
-                targetObjectCtClass, null, model, null);
-
-        ct.removeField("_fieldToRemove");
-
-        ct.finish();
-
-        Class transformed = toClass(targetObjectCtClass);
-
-        for (Field f : transformed.getDeclaredFields())
-        {
-            if (f.getName().equals("_fieldToRemove"))
-                throw new AssertionError("_fieldToRemove still in transformed 
class.");
-        }
-
-        verify();
-    }
 
+  
     @Test
     public void get_method_identifier() throws Exception
     {
@@ -1489,8 +1135,7 @@
 
         replay();
 
-        InternalClassTransformation parentTransform = 
createClassTransformation(SimpleBean.class,
-                logger);
+        InternalClassTransformation parentTransform = 
createClassTransformation(SimpleBean.class, logger);
 
         parentTransform.finish();
 
@@ -1501,8 +1146,8 @@
 
         assertFalse(childTransform.isMethodOverride(new 
TransformMethodSignature("notOverridden")));
 
-        assertTrue(childTransform.isMethodOverride(new 
TransformMethodSignature(Modifier.PUBLIC,
-                "void", "setAge", new String[]
+        assertTrue(childTransform.isMethodOverride(new 
TransformMethodSignature(Modifier.PUBLIC, "void", "setAge",
+                new String[]
                 { "int" }, null)));
     }
 


Reply via email to