Author: hlship
Date: Wed Aug 10 00:51:00 2011
New Revision: 1155984
URL: http://svn.apache.org/viewvc?rev=1155984&view=rev
Log:
Refactor out a method for enabling logging of generated byte code
Modified:
tapestry/tapestry5/trunk/plastic/src/test/groovy/org/apache/tapestry5/plastic/AbstractPlasticSpecification.groovy
tapestry/tapestry5/trunk/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldConduitTests.groovy
tapestry/tapestry5/trunk/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodAdviceTests.groovy
Modified:
tapestry/tapestry5/trunk/plastic/src/test/groovy/org/apache/tapestry5/plastic/AbstractPlasticSpecification.groovy
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/plastic/src/test/groovy/org/apache/tapestry5/plastic/AbstractPlasticSpecification.groovy?rev=1155984&r1=1155983&r2=1155984&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/plastic/src/test/groovy/org/apache/tapestry5/plastic/AbstractPlasticSpecification.groovy
(original)
+++
tapestry/tapestry5/trunk/plastic/src/test/groovy/org/apache/tapestry5/plastic/AbstractPlasticSpecification.groovy
Wed Aug 10 00:51:00 2011
@@ -1,25 +1,37 @@
package org.apache.tapestry5.plastic
import org.apache.tapestry5.internal.plastic.StandardDelegate
-
import spock.lang.Specification
-abstract class AbstractPlasticSpecification extends Specification {
-
+abstract class AbstractPlasticSpecification extends Specification
+{
+
def mgr = PlasticManager.withContextClassLoader().create()
-
- PlasticMethod findMethod(pc, name) {
+
+ PlasticMethod findMethod(pc, name)
+ {
pc.methods.find { it.description.methodName == name }
}
- MethodHandle findHandle(pc, name) {
+ MethodHandle findHandle(pc, name)
+ {
findMethod(pc, name)?.handle
}
- PlasticManager createMgr(PlasticClassTransformer... transformers) {
+ PlasticManager createMgr(PlasticClassTransformer... transformers)
+ {
def delegate = new StandardDelegate(transformers)
- def packages = ["testsubjects"]as Set
+ def packages = ["testsubjects"] as Set
return
PlasticManager.withContextClassLoader().delegate(delegate).packages(packages).create()
}
+
+ void enableBytecodeDebugging(PlasticManager mgr)
+ {
+ mgr.addPlasticClassListener({ PlasticClassEvent event ->
+
+ print(event.getDissasembledBytecode())
+
+ } as PlasticClassListener)
+ }
}
Modified:
tapestry/tapestry5/trunk/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldConduitTests.groovy
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldConduitTests.groovy?rev=1155984&r1=1155983&r2=1155984&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldConduitTests.groovy
(original)
+++
tapestry/tapestry5/trunk/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldConduitTests.groovy
Wed Aug 10 00:51:00 2011
@@ -219,11 +219,7 @@ class FieldConduitTests extends Abstract
// Needed this when debugging an issue:
if (false)
{
- mgr.addPlasticClassListener({ PlasticClassEvent event ->
-
- print(event.getDissasembledBytecode())
-
- } as PlasticClassListener)
+ enableBytecodeDebugging(mgr)
}
def o =
mgr.getClassInstantiator("testsubjects.InjectSubClass").newInstance()
Modified:
tapestry/tapestry5/trunk/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodAdviceTests.groovy
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodAdviceTests.groovy?rev=1155984&r1=1155983&r2=1155984&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodAdviceTests.groovy
(original)
+++
tapestry/tapestry5/trunk/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodAdviceTests.groovy
Wed Aug 10 00:51:00 2011
@@ -221,6 +221,7 @@ class MethodAdviceTests extends Abstract
pc.getMethodsWithAnnotation(MethodAnnotation.class).each({ m ->
m.addAdvice(justProceed)
+ m.addAdvice(justProceed)
})
pc.getFieldsWithAnnotation(FieldAnnotation.class).each({ f ->
@@ -228,6 +229,8 @@ class MethodAdviceTests extends Abstract
})
} as PlasticClassTransformer)
+ if (false) { enableBytecodeDebugging(mgr) }
+
def o =
mgr.getClassInstantiator("testsubjects.FieldConduitInsideAdvisedMethod").with(MagicContainer.class,
container).newInstance()
when: