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 2012/04/02 22:37:38 UTC
svn commit: r1308540 - in
/tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5:
internal/plastic/ plastic/
Author: hlship
Date: Mon Apr 2 20:37:37 2012
New Revision: 1308540
URL: http://svn.apache.org/viewvc?rev=1308540&view=rev
Log:
Make the plastic tests use more idiomatic Groovy
Do not use the .class keyword to reference a Java Class
Modified:
tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/internal/plastic/ClassInstantiatorTests.groovy
tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/internal/plastic/PlasticUtilsTests.groovy
tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ArrayAttributeAnnotations.groovy
tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ClassAnnotationAccess.groovy
tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ConstructorCallbackTests.groovy
tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldAccessTests.groovy
tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldAnnotationAccess.groovy
tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldConduitTests.groovy
tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldInjection.groovy
tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldPropertyMethodCreation.groovy
tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/IntroduceFieldTests.groovy
tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodAdviceTests.groovy
tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodAnnotationAccess.groovy
tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodHandleAccess.groovy
tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodIntroduction.groovy
tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodProxying.groovy
tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ObtainPlasticClass.groovy
tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ParameterAnnotationsTest.groovy
tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ProxyCreation.groovy
tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/SimpleClassLoading.groovy
tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/StaticFieldAccess.groovy
tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ToStringTests.groovy
Modified: tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/internal/plastic/ClassInstantiatorTests.groovy
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/internal/plastic/ClassInstantiatorTests.groovy?rev=1308540&r1=1308539&r2=1308540&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/internal/plastic/ClassInstantiatorTests.groovy (original)
+++ tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/internal/plastic/ClassInstantiatorTests.groovy Mon Apr 2 20:37:37 2012
@@ -1,46 +1,35 @@
-// Copyright 2011 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.tapestry5.internal.plastic
-import java.text.DateFormat
-
import spock.lang.Specification
import testsubjects.ContextCatcher
+import java.text.DateFormat
+
class ClassInstantiatorTests extends Specification
{
- def ins = new ClassInstantiatorImpl(ContextCatcher.class, ContextCatcher.class.constructors[0], null)
+ def ins = new ClassInstantiatorImpl(ContextCatcher, ContextCatcher.constructors[0], null)
def "adding a context value returns a new instantiator"() {
String value = "instance value of type String";
when:
- def ins2 = ins.with(String.class, value)
+ def ins2 = ins.with(String, value)
then:
! ins2.is(ins)
- ins2.get(String.class).is(value)
+ ins2.get(String).is(value)
}
def "may not add a duplicate instance context value"() {
+ given:
+ def ins2 = ins.with(String, "initial value")
+
when:
- ins.with(String.class, "initial value").with(String.class, "conflicting value")
+ ins2.with(String, "conflicting value")
then:
def e = thrown(IllegalStateException)
@@ -50,7 +39,7 @@ class ClassInstantiatorTests extends Spe
def "get a value not stored is a failure"() {
when:
- ins.get(DateFormat.class)
+ ins.get(DateFormat)
then:
def e = thrown(IllegalArgumentException)
@@ -62,10 +51,10 @@ class ClassInstantiatorTests extends Spe
when:
- def o = ins.with(String.class, value).newInstance()
+ def o = ins.with(String, value).newInstance()
then:
- o.instanceContext.get(String.class).is(value)
+ o.instanceContext.get(String).is(value)
}
}
Modified: tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/internal/plastic/PlasticUtilsTests.groovy
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/internal/plastic/PlasticUtilsTests.groovy?rev=1308540&r1=1308539&r2=1308540&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/internal/plastic/PlasticUtilsTests.groovy (original)
+++ tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/internal/plastic/PlasticUtilsTests.groovy Mon Apr 2 20:37:37 2012
@@ -1,17 +1,3 @@
-// Copyright 2011, 2012 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.tapestry5.internal.plastic
import org.apache.tapestry5.plastic.PlasticUtils
@@ -55,13 +41,13 @@ class PlasticUtilsTests extends Specific
where:
javaName | expectedClass
- "java.lang.String" | String.class
- "java.lang.Integer[]" | Integer[].class
- "java.lang.Long[][]" | Long[][].class
- "void" | void.class
- "int" | int.class
- "int[]" | int[].class
- "float[][]" | float[][].class
+ "java.lang.String" | String
+ "java.lang.Integer[]" | Integer[]
+ "java.lang.Long[][]" | Long[][]
+ "void" | void
+ "int" | int
+ "int[]" | int[]
+ "float[][]" | float[][]
}
def "not object descriptor is an exception"()
@@ -140,10 +126,10 @@ class PlasticUtilsTests extends Specific
primitiveType | wrapperType
- String.class | String.class
- boolean.class | Boolean.class
- double.class | Double.class
- int[].class | int[].class
+ String | String
+ boolean | Boolean
+ double | Double
+ int[] | int[]
}
def "isPrimitive #name should be #expected"()
Modified: tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ArrayAttributeAnnotations.groovy
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ArrayAttributeAnnotations.groovy?rev=1308540&r1=1308539&r2=1308540&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ArrayAttributeAnnotations.groovy (original)
+++ tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ArrayAttributeAnnotations.groovy Mon Apr 2 20:37:37 2012
@@ -1,10 +1,7 @@
package org.apache.tapestry5.plastic
-import org.apache.tapestry5.plastic.PlasticManager;
-
-import spock.lang.Specification;
-import testannotations.ArrayAnnotation;
-import testannotations.Truth;
+import testannotations.ArrayAnnotation
+import testannotations.Truth
class ArrayAttributeAnnotations extends AbstractPlasticSpecification {
@@ -12,7 +9,7 @@ class ArrayAttributeAnnotations extends
when:
def pc = mgr.getPlasticClass("testsubjects.AnnotationSubject")
- def a = pc.getAnnotation(ArrayAnnotation.class)
+ def a = pc.getAnnotation(ArrayAnnotation)
then:
a.numbers().length == 0
@@ -24,7 +21,7 @@ class ArrayAttributeAnnotations extends
def "explicit values for array attributes"() {
when:
def pc = mgr.getPlasticClass("testsubjects.ArrayAttributesSubject")
- def a = pc.getAnnotation(ArrayAnnotation.class)
+ def a = pc.getAnnotation(ArrayAnnotation)
then:
@@ -32,7 +29,7 @@ class ArrayAttributeAnnotations extends
a.strings() == ["frodo", "sam"]
- a.types() == [Runnable.class]
+ a.types() == [Runnable]
a.annotations().length == 2
a.annotations()[0].value() == Truth.YES
@@ -43,7 +40,7 @@ class ArrayAttributeAnnotations extends
when:
def pc = mgr.getPlasticClass("testsubjects.ExplicityEmptyArrayAttributesSubject")
- def a = pc.getAnnotation(ArrayAnnotation.class)
+ def a = pc.getAnnotation(ArrayAnnotation)
then:
a.numbers().length == 0
Modified: tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ClassAnnotationAccess.groovy
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ClassAnnotationAccess.groovy?rev=1308540&r1=1308539&r2=1308540&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ClassAnnotationAccess.groovy (original)
+++ tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ClassAnnotationAccess.groovy Mon Apr 2 20:37:37 2012
@@ -1,10 +1,7 @@
package org.apache.tapestry5.plastic
-import org.apache.tapestry5.plastic.PlasticManager;
-
-import spock.lang.Specification;
-import testannotations.InheritedAnnotation;
-import testannotations.SimpleAnnotation;
+import testannotations.InheritedAnnotation
+import testannotations.SimpleAnnotation
class ClassAnnotationAccess extends AbstractPlasticSpecification {
@@ -14,22 +11,22 @@ class ClassAnnotationAccess extends Abst
expect:
- pc.hasAnnotation(Deprecated.class) == false
- pc.getAnnotation(Deprecated.class) == null
+ pc.hasAnnotation(Deprecated) == false
+ pc.getAnnotation(Deprecated) == null
}
def "check existence of known, simple annotation"() {
expect:
- pc.hasAnnotation(SimpleAnnotation.class) == true
+ pc.hasAnnotation(SimpleAnnotation) == true
when:
- def a = pc.getAnnotation(SimpleAnnotation.class)
+ def a = pc.getAnnotation(SimpleAnnotation)
then:
a instanceof SimpleAnnotation
- a.annotationType() == SimpleAnnotation.class
+ a.annotationType() == SimpleAnnotation
a.toString() == "@testannotations.SimpleAnnotation"
}
@@ -38,6 +35,6 @@ class ClassAnnotationAccess extends Abst
def pc = mgr.getPlasticClass("testsubjects.InheritedAnnotationSubClass")
expect:
- pc.hasAnnotation(InheritedAnnotation.class) == true
+ pc.hasAnnotation(InheritedAnnotation) == true
}
}
Modified: tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ConstructorCallbackTests.groovy
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ConstructorCallbackTests.groovy?rev=1308540&r1=1308539&r2=1308540&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ConstructorCallbackTests.groovy (original)
+++ tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ConstructorCallbackTests.groovy Mon Apr 2 20:37:37 2012
@@ -1,17 +1,3 @@
-// Copyright 2011 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.tapestry5.plastic
class ConstructorCallbackTests extends AbstractPlasticSpecification
@@ -24,7 +10,7 @@ class ConstructorCallbackTests extends A
def mgr = createMgr({ PlasticClass pc ->
- fieldHandle = pc.introduceField(String.class, "newField").inject(injectedValue).handle
+ fieldHandle = pc.introduceField(String, "newField").inject(injectedValue).handle
pc.onConstruct({ instance, context ->
Modified: tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldAccessTests.groovy
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldAccessTests.groovy?rev=1308540&r1=1308539&r2=1308540&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldAccessTests.groovy (original)
+++ tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldAccessTests.groovy Mon Apr 2 20:37:37 2012
@@ -51,13 +51,13 @@ class FieldAccessTests extends AbstractP
PlasticClassTransformer installFieldConduit = { PlasticClass pc ->
- pc.getFieldsWithAnnotation(SimpleAnnotation.class).each { f -> f.setConduit(fc) }
+ pc.getFieldsWithAnnotation(SimpleAnnotation).each { f -> f.setConduit(fc) }
} as PlasticClassTransformer
PlasticClassTransformer handleInjection = { PlasticClass pc ->
- pc.getFieldsWithAnnotation(KindaInject.class).each { f -> f.inject(delegate) }
+ pc.getFieldsWithAnnotation(KindaInject).each { f -> f.inject(delegate) }
} as PlasticClassTransformer
def mgr = createMgr(installFieldConduit, handleInjection)
Modified: tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldAnnotationAccess.groovy
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldAnnotationAccess.groovy?rev=1308540&r1=1308539&r2=1308540&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldAnnotationAccess.groovy (original)
+++ tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldAnnotationAccess.groovy Mon Apr 2 20:37:37 2012
@@ -11,7 +11,7 @@ class FieldAnnotationAccess extends Abst
def pc = mgr.getPlasticClass("testsubjects.AnnotationSubject")
when:
- def fields = pc.getFieldsWithAnnotation(Maybe.class)
+ def fields = pc.getFieldsWithAnnotation(Maybe)
then:
fields.size() == 1
Modified: tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldConduitTests.groovy
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldConduitTests.groovy?rev=1308540&r1=1308539&r2=1308540&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldConduitTests.groovy (original)
+++ tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldConduitTests.groovy Mon Apr 2 20:37:37 2012
@@ -1,17 +1,3 @@
-// Copyright 2011 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.tapestry5.plastic
import testannotations.KindaInject
@@ -207,7 +193,7 @@ class FieldConduitTests extends Abstract
FieldConduit conduit = Mock(FieldConduit)
PlasticClassTransformer transformer = { PlasticClass pc ->
- pc.getFieldsWithAnnotation(KindaInject.class).each({
+ pc.getFieldsWithAnnotation(KindaInject).each({
PlasticField field -> field.setConduit(conduit)
})
} as PlasticClassTransformer
Modified: tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldInjection.groovy
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldInjection.groovy?rev=1308540&r1=1308539&r2=1308540&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldInjection.groovy (original)
+++ tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldInjection.groovy Mon Apr 2 20:37:37 2012
@@ -1,21 +1,5 @@
-// Copyright 2011 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.tapestry5.plastic
-import java.util.logging.Logger
-import testannotations.KindaInject
import testsubjects.StringPropertyHolder
class FieldInjection extends AbstractPlasticSpecification
@@ -51,17 +35,17 @@ class FieldInjection extends AbstractPla
instanceType = it.instanceType
- return it.get(String.class)
+ return it.get(String)
} as ComputedValue)
- def o = pc.createInstantiator().with(String.class, injected).newInstance()
+ def o = pc.createInstantiator().with(String, injected).newInstance()
expect:
o.value.is(injected)
instanceType.is(o.getClass())
- !instanceType.is(StringPropertyHolder.class) // it's a new class with the same name
+ !instanceType.is(StringPropertyHolder) // it's a new class with the same name
when:
o.value = "attempt to update"
@@ -79,7 +63,7 @@ class FieldInjection extends AbstractPla
pc.allFields.first().injectFromInstanceContext()
- def o = pc.createInstantiator().with(String.class, injected).newInstance()
+ def o = pc.createInstantiator().with(String, injected).newInstance()
expect:
Modified: tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldPropertyMethodCreation.groovy
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldPropertyMethodCreation.groovy?rev=1308540&r1=1308539&r2=1308540&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldPropertyMethodCreation.groovy (original)
+++ tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldPropertyMethodCreation.groovy Mon Apr 2 20:37:37 2012
@@ -1,33 +1,18 @@
-// Copyright 2011 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.tapestry5.plastic
-import java.util.concurrent.atomic.AtomicReference
-
-import spock.lang.Specification
import testannotations.Property
-import testsubjects.AccessorsAlreadyExistSubject;
+import testsubjects.AccessorsAlreadyExistSubject
import testsubjects.CreateAccessorsSubject
import testsubjects.GenericCreateAccessorsSubject
+import java.util.concurrent.atomic.AtomicReference
+
class FieldPropertyMethodCreation extends AbstractPlasticSpecification
{
def withAccessors(Class subject, PropertyAccessType accessType) {
def pc = mgr.getPlasticClass (subject.name)
- pc.getFieldsWithAnnotation(Property.class).each { f ->
+ pc.getFieldsWithAnnotation(Property).each { f ->
f.createAccessors(accessType)
}
@@ -36,7 +21,7 @@ class FieldPropertyMethodCreation extend
def "create accessors for fields"() {
- def o = withAccessors(CreateAccessorsSubject.class, PropertyAccessType.READ_WRITE)
+ def o = withAccessors(CreateAccessorsSubject, PropertyAccessType.READ_WRITE)
when:
@@ -71,7 +56,7 @@ class FieldPropertyMethodCreation extend
def "create accessors for generic fields"() {
- def o = withAccessors(GenericCreateAccessorsSubject.class, PropertyAccessType.READ_WRITE)
+ def o = withAccessors(GenericCreateAccessorsSubject, PropertyAccessType.READ_WRITE)
def ref = new AtomicReference<String>("Plastic")
@@ -86,7 +71,7 @@ class FieldPropertyMethodCreation extend
get.signature == "()Ljava/util/concurrent/atomic/AtomicReference<Ljava/lang/String;>;"
get.genericInfo != null
- def set = o.class.getMethod("setRef", AtomicReference.class)
+ def set = o.class.getMethod("setRef", AtomicReference)
set.signature == "(Ljava/util/concurrent/atomic/AtomicReference<Ljava/lang/String;>;)V"
set.genericInfo != null
}
@@ -94,7 +79,7 @@ class FieldPropertyMethodCreation extend
def "create getter that already exists"() {
when:
- withAccessors(AccessorsAlreadyExistSubject.class, PropertyAccessType.READ_ONLY)
+ withAccessors(AccessorsAlreadyExistSubject, PropertyAccessType.READ_ONLY)
then:
@@ -106,7 +91,7 @@ class FieldPropertyMethodCreation extend
def "create setter that already exists"() {
when:
- withAccessors(AccessorsAlreadyExistSubject.class, PropertyAccessType.WRITE_ONLY)
+ withAccessors(AccessorsAlreadyExistSubject, PropertyAccessType.WRITE_ONLY)
then:
Modified: tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/IntroduceFieldTests.groovy
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/IntroduceFieldTests.groovy?rev=1308540&r1=1308539&r2=1308540&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/IntroduceFieldTests.groovy (original)
+++ tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/IntroduceFieldTests.groovy Mon Apr 2 20:37:37 2012
@@ -1,17 +1,3 @@
-// Copyright 2011 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.tapestry5.plastic
import java.lang.reflect.Modifier
@@ -79,6 +65,6 @@ class IntroduceFieldTests extends Abstra
expect:
f.modifiers == Modifier.PRIVATE
- f.type == Integer.class
+ f.type == Integer
}
}
Modified: tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodAdviceTests.groovy
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodAdviceTests.groovy?rev=1308540&r1=1308539&r2=1308540&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodAdviceTests.groovy (original)
+++ tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodAdviceTests.groovy Mon Apr 2 20:37:37 2012
@@ -1,6 +1,5 @@
package org.apache.tapestry5.plastic
-import java.sql.SQLException
import org.apache.tapestry5.plastic.test.NoopAdvice
import testannotations.FieldAnnotation
import testannotations.Maybe
@@ -8,6 +7,8 @@ import testannotations.MethodAnnotation
import testannotations.Truth
import testinterfaces.MagicContainer
+import java.sql.SQLException
+
class MethodAdviceTests extends AbstractPlasticSpecification
{
def "advice for a void method"()
@@ -30,10 +31,10 @@ class MethodAdviceTests extends Abstract
assert it.getParameter(0) == 123
- assert it.hasAnnotation(Deprecated.class) == false
- assert it.hasAnnotation(Maybe.class) == true
+ assert it.hasAnnotation(Deprecated) == false
+ assert it.hasAnnotation(Maybe) == true
- assert it.getAnnotation(Maybe.class).value() == Truth.YES
+ assert it.getAnnotation(Maybe).value() == Truth.YES
it.proceed()
} as MethodAdvice)
@@ -162,11 +163,11 @@ class MethodAdviceTests extends Abstract
def mgr = createMgr({ PlasticClass pc ->
- pc.getMethodsWithAnnotation(MethodAnnotation.class).each({ m ->
+ pc.getMethodsWithAnnotation(MethodAnnotation).each({ m ->
m.addAdvice(justProceed)
})
- pc.getFieldsWithAnnotation(FieldAnnotation.class).each({ f ->
+ pc.getFieldsWithAnnotation(FieldAnnotation).each({ f ->
f.setConduit(fc)
})
} as PlasticClassTransformer)
@@ -188,11 +189,11 @@ class MethodAdviceTests extends Abstract
def mgr = createMgr({ PlasticClass pc ->
- pc.getFieldsWithAnnotation(FieldAnnotation.class).each({ f ->
+ pc.getFieldsWithAnnotation(FieldAnnotation).each({ f ->
f.setConduit(fc)
})
- pc.getMethodsWithAnnotation(MethodAnnotation.class).each({ m ->
+ pc.getMethodsWithAnnotation(MethodAnnotation).each({ m ->
m.addAdvice(justProceed)
})
@@ -211,7 +212,7 @@ class MethodAdviceTests extends Abstract
FieldConduit fc = [get: { instance, context ->
- return context.get(MagicContainer.class).magic()
+ return context.get(MagicContainer).magic()
}, set: { instance, context -> }] as FieldConduit
@@ -219,18 +220,18 @@ class MethodAdviceTests extends Abstract
def mgr = createMgr({ PlasticClass pc ->
- pc.getMethodsWithAnnotation(MethodAnnotation.class).each({ m ->
+ pc.getMethodsWithAnnotation(MethodAnnotation).each({ m ->
m.addAdvice(justProceed)
})
- pc.getFieldsWithAnnotation(FieldAnnotation.class).each({ f ->
+ pc.getFieldsWithAnnotation(FieldAnnotation).each({ f ->
f.setConduit(fc)
})
} as PlasticClassTransformer)
if (false) { enableBytecodeDebugging(mgr) }
- def o = mgr.getClassInstantiator("testsubjects.FieldConduitInsideAdvisedMethod").with(MagicContainer.class, container).newInstance()
+ def o = mgr.getClassInstantiator("testsubjects.FieldConduitInsideAdvisedMethod").with(MagicContainer, container).newInstance()
when:
@@ -247,7 +248,7 @@ class MethodAdviceTests extends Abstract
FieldConduit fc = [get: { instance, context ->
- return context.get(MagicContainer.class)
+ return context.get(MagicContainer)
}, set: { instance, context -> }] as FieldConduit
@@ -255,18 +256,18 @@ class MethodAdviceTests extends Abstract
def mgr = createMgr({ PlasticClass pc ->
- pc.getMethodsWithAnnotation(MethodAnnotation.class).each({ m ->
+ pc.getMethodsWithAnnotation(MethodAnnotation).each({ m ->
m.addAdvice(justProceed)
})
- pc.getFieldsWithAnnotation(FieldAnnotation.class).each({ f ->
+ pc.getFieldsWithAnnotation(FieldAnnotation).each({ f ->
f.setConduit(fc)
})
} as PlasticClassTransformer)
if (false) { enableBytecodeDebugging(mgr) }
- def o = mgr.getClassInstantiator("testsubjects.FieldConduitAdvisedMethodComplexCase").with(MagicContainer.class, container).newInstance()
+ def o = mgr.getClassInstantiator("testsubjects.FieldConduitAdvisedMethodComplexCase").with(MagicContainer, container).newInstance()
when:
Modified: tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodAnnotationAccess.groovy
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodAnnotationAccess.groovy?rev=1308540&r1=1308539&r2=1308540&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodAnnotationAccess.groovy (original)
+++ tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodAnnotationAccess.groovy Mon Apr 2 20:37:37 2012
@@ -13,7 +13,7 @@ class MethodAnnotationAccess extends Abs
when:
- def methods = pc.getMethodsWithAnnotation(Maybe.class)
+ def methods = pc.getMethodsWithAnnotation(Maybe)
def noMethod = methods[0]
def yesMethod = methods[1]
@@ -24,30 +24,30 @@ class MethodAnnotationAccess extends Abs
noMethod.description.methodName == "no"
yesMethod.description.methodName == "yes"
- noMethod.getAnnotation(Maybe.class).value() == Truth.NO
- yesMethod.getAnnotation(Maybe.class).value() == Truth.YES
+ noMethod.getAnnotation(Maybe).value() == Truth.NO
+ yesMethod.getAnnotation(Maybe).value() == Truth.YES
}
def "method annotation with primitive attributes"() {
when:
- def methods = pc.getMethodsWithAnnotation(PrimitiveValues.class)
+ def methods = pc.getMethodsWithAnnotation(PrimitiveValues)
then:
methods.size == 1
when:
- def pv = methods[0].getAnnotation(PrimitiveValues.class)
+ def pv = methods[0].getAnnotation(PrimitiveValues)
then:
pv.count() == 5
pv.title() == "runnables" // explicit
- pv.type() == Runnable.class
+ pv.type() == Runnable
pv.message() == "created" // default
}
def "nested annotation as attribute of outer annotation"() {
when:
- def ann = pc.getMethodsWithAnnotation(Outer.class)[0].getAnnotation(Outer.class)
+ def ann = pc.getMethodsWithAnnotation(Outer)[0].getAnnotation(Outer)
then:
ann.maybe().value() == Truth.YES
Modified: tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodHandleAccess.groovy
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodHandleAccess.groovy?rev=1308540&r1=1308539&r2=1308540&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodHandleAccess.groovy (original)
+++ tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodHandleAccess.groovy Mon Apr 2 20:37:37 2012
@@ -53,7 +53,7 @@ class MethodHandleAccess extends Abstrac
result.returnValue == null
result.didThrowCheckedException() == true
- def e = result.getCheckedException(WillNotDoubleException.class)
+ def e = result.getCheckedException(WillNotDoubleException)
}
// This also tests object references as parameters and return values (other tests
Modified: tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodIntroduction.groovy
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodIntroduction.groovy?rev=1308540&r1=1308539&r2=1308540&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodIntroduction.groovy (original)
+++ tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodIntroduction.groovy Mon Apr 2 20:37:37 2012
@@ -1,6 +1,5 @@
package org.apache.tapestry5.plastic
-
class MethodIntroduction extends AbstractPlasticSpecification
{
@@ -46,12 +45,12 @@ class MethodIntroduction extends Abstrac
"java.lang.String" | "getString" | { it.getString() } | null | null
"java.util.Date[]" | "getDates" | { it.getDates() } | null | null
- "int" | "getInt" | { it.getInt() } | 0 | Integer.class
+ "int" | "getInt" | { it.getInt() } | 0 | Integer
"int[]" | "getInts" | { it.getInts() } | null | null
- "char" | "getChar" | { it.getChar() } | 0 | Character.class
- "float" | "getFloat" | { it.getFloat() } | 0f | Float.class
- "long" | "getLong" | { it.getLong() } | 0l | Long.class
- "double" | "getDouble" | { it.getDouble() } | 0d | Double.class
+ "char" | "getChar" | { it.getChar() } | 0 | Character
+ "float" | "getFloat" | { it.getFloat() } | 0f | Float
+ "long" | "getLong" | { it.getLong() } | 0l | Long
+ "double" | "getDouble" | { it.getDouble() } | 0d | Double
}
def "introduce void method override"()
@@ -102,7 +101,7 @@ class MethodIntroduction extends Abstrac
def mgr = createMgr({ PlasticClass pc ->
if (pc.className == CLASS_NAME)
- introduced = pc.introduceInterface(Runnable.class).collect { it.description }
+ introduced = pc.introduceInterface(Runnable).collect { it.description }
} as PlasticClassTransformer)
when:
@@ -129,12 +128,12 @@ class MethodIntroduction extends Abstrac
PlasticClass pc ->
if (pc.className.contains("Base"))
{
- pc.introduceInterface(Serializable.class)
+ pc.introduceInterface(Serializable)
}
if (pc.className.contains("Child"))
{
- present = pc.isInterfaceImplemented(Serializable.class)
+ present = pc.isInterfaceImplemented(Serializable)
}
} as PlasticClassTransformer)
Modified: tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodProxying.groovy
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodProxying.groovy?rev=1308540&r1=1308539&r2=1308540&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodProxying.groovy (original)
+++ tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodProxying.groovy Mon Apr 2 20:37:37 2012
@@ -7,18 +7,18 @@ class MethodProxying extends AbstractPla
def "basic proxying"() {
setup:
- def mockRunnable = Mock(Runnable.class)
+ def mockRunnable = Mock(Runnable)
- def o = mgr.createClass (Object.class, { PlasticClass pc ->
+ def o = mgr.createClass (Object, { PlasticClass pc ->
- def field = pc.introduceField (Runnable.class, "delegate").inject(mockRunnable)
+ def field = pc.introduceField (Runnable, "delegate").inject(mockRunnable)
- pc.proxyInterface (Runnable.class, field)
+ pc.proxyInterface (Runnable, field)
} as PlasticClassTransformer).newInstance()
expect:
- Runnable.class.isInstance o
+ Runnable.isInstance o
when:
@@ -35,11 +35,11 @@ class MethodProxying extends AbstractPla
def handle
def methodToString
- def o = mgr.createClass(Object.class, { PlasticClass pc ->
+ def o = mgr.createClass(Object, { PlasticClass pc ->
- def field = pc.introduceField(Memory.class, "delegate").inject(new Memory())
+ def field = pc.introduceField(Memory, "delegate").inject(new Memory())
- def m = Memory.class.getMethod("returnLast", long.class)
+ def m = Memory.getMethod("returnLast", long)
def pm = pc.introduceMethod(m)
@@ -65,11 +65,11 @@ class MethodProxying extends AbstractPla
def handle
- def o = mgr.createClass(Object.class, { PlasticClass pc ->
+ def o = mgr.createClass(Object, { PlasticClass pc ->
def memory = new Memory()
- PlasticMethod providerMethod = pc.introduceMethod(new MethodDescription(Memory.class.name, "provideDelegate")).addAdvice({ MethodInvocation mi ->
+ PlasticMethod providerMethod = pc.introduceMethod(new MethodDescription(Memory.name, "provideDelegate")).addAdvice({ MethodInvocation mi ->
mi.returnValue = memory
@@ -77,7 +77,7 @@ class MethodProxying extends AbstractPla
} as MethodAdvice)
- def m = Memory.class.getMethod("returnLast", long.class)
+ def m = Memory.getMethod("returnLast", long)
def pm = pc.introduceMethod(m)
Modified: tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ObtainPlasticClass.groovy
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ObtainPlasticClass.groovy?rev=1308540&r1=1308539&r2=1308540&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ObtainPlasticClass.groovy (original)
+++ tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ObtainPlasticClass.groovy Mon Apr 2 20:37:37 2012
@@ -1,23 +1,9 @@
-// Copyright 2011 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.tapestry5.plastic
-import java.lang.reflect.InvocationTargetException
-
import org.apache.tapestry5.internal.plastic.NoopDelegate
+import java.lang.reflect.InvocationTargetException
+
class ObtainPlasticClass extends AbstractPlasticSpecification
{
def "abstract classes may not be instantiated"() {
@@ -128,13 +114,13 @@ class ObtainPlasticClass extends Abstrac
when:
- clazz.getConstructor([String.class]as Class[]).newInstance([null]as Object[])
+ clazz.getConstructor([String] as Class[]).newInstance([null]as Object[])
then:
def e = thrown(InvocationTargetException)
- e.cause.getClass() == IllegalStateException.class
+ e.cause.class == IllegalStateException
e.cause.message == "Class testsubjects.AlternateConstructor has been transformed and may not be directly instantiated."
@@ -146,7 +132,7 @@ class ObtainPlasticClass extends Abstrac
e = thrown(InvocationTargetException)
- e.cause.getClass() == IllegalStateException.class
+ e.cause.class == IllegalStateException
e.cause.message == "Class testsubjects.AlternateConstructor has been transformed and may not be directly instantiated."
}
Modified: tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ParameterAnnotationsTest.groovy
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ParameterAnnotationsTest.groovy?rev=1308540&r1=1308539&r2=1308540&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ParameterAnnotationsTest.groovy (original)
+++ tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ParameterAnnotationsTest.groovy Mon Apr 2 20:37:37 2012
@@ -18,14 +18,14 @@ public class ParameterAnnotationsTest ex
params.size() == 2
- params[0].type == String.class.name
+ params[0].type == String.name
params[0].index == 0
- params[0].hasAnnotation(TestInject.class)
- params[0].getAnnotation(TestInject.class) instanceof TestInject
+ params[0].hasAnnotation(TestInject)
+ params[0].getAnnotation(TestInject) instanceof TestInject
params[1].type == "int"
params[1].index == 1
- params[1].hasAnnotation(TestInject.class) == false
+ params[1].hasAnnotation(TestInject) == false
}
}
Modified: tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ProxyCreation.groovy
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ProxyCreation.groovy?rev=1308540&r1=1308539&r2=1308540&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ProxyCreation.groovy (original)
+++ tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ProxyCreation.groovy Mon Apr 2 20:37:37 2012
@@ -7,8 +7,8 @@ class ProxyCreation extends AbstractPlas
Runnable r = Mock(Runnable)
- def ins = mgr.createProxy(Runnable.class, {
- def f = it.introduceField(Runnable.class, "delegate").inject(r)
+ def ins = mgr.createProxy(Runnable, {
+ def f = it.introduceField(Runnable, "delegate").inject(r)
it.introduceMethod(new MethodDescription("void", "run")).delegateTo(f)
} as PlasticClassTransformer)
@@ -36,11 +36,11 @@ class ProxyCreation extends AbstractPlas
Runnable r = Mock(Runnable)
- def ins = mgr.createProxy(Runnable.class, {
+ def ins = mgr.createProxy(Runnable, {
PlasticClass pc ->
- def f = pc.introduceField(Runnable.class, "delegate").inject(r)
+ def f = pc.introduceField(Runnable, "delegate").inject(r)
- PlasticMethod dm = pc.introducePrivateMethod(Runnable.class.name, "run", null, null)
+ PlasticMethod dm = pc.introducePrivateMethod(Runnable.name, "run", null, null)
assert dm.description.methodName != "run"
@@ -48,7 +48,7 @@ class ProxyCreation extends AbstractPlas
it.loadThis().getField(f).returnResult()
} as InstructionBuilderCallback)
- Runnable.class.methods.each( { m -> pc.introduceMethod(m).delegateTo(dm) })
+ Runnable.methods.each( { m -> pc.introduceMethod(m).delegateTo(dm) })
pc.introduceMethod(new MethodDescription("void", "run")).delegateTo(f)
} as PlasticClassTransformer)
@@ -74,7 +74,7 @@ class ProxyCreation extends AbstractPlas
def "type must be an interface"() {
when:
- mgr.createProxy (String.class, {
+ mgr.createProxy (String, {
} as PlasticClassTransformer)
then:
@@ -96,8 +96,8 @@ class ProxyCreation extends AbstractPlas
mgr.addPlasticClassListener listener
- def ins = mgr.createProxy(Runnable.class, {
- def f = it.introduceField(Runnable.class, "delegate").inject(r)
+ def ins = mgr.createProxy(Runnable, {
+ def f = it.introduceField(Runnable, "delegate").inject(r)
it.introduceMethod(new MethodDescription("void", "run")).delegateTo(f)
} as PlasticClassTransformer)
Modified: tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/SimpleClassLoading.groovy
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/SimpleClassLoading.groovy?rev=1308540&r1=1308539&r2=1308540&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/SimpleClassLoading.groovy (original)
+++ tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/SimpleClassLoading.groovy Mon Apr 2 20:37:37 2012
@@ -1,12 +1,10 @@
package org.apache.tapestry5.plastic
-import java.util.concurrent.Callable
-
-import org.apache.tapestry5.plastic.PlasticClassTransformer;
-
import testsubjects.InjectionSubject
import testsubjects.TestInjectTransformer
+import java.util.concurrent.Callable
+
/**
* This is the first test that integrates the class loader with the PlasticManager, simulating how Plastic will
* be used in the wild.
@@ -17,10 +15,10 @@ class SimpleClassLoading extends Abstrac
def "basic field transformation"() {
setup:
- def concreteClass = InjectionSubject.class
+ def concreteClass = InjectionSubject
def goHandle
- def runnable = Mock(Runnable.class)
- def transformer = new TestInjectTransformer(Runnable.class, runnable)
+ def runnable = Mock(Runnable)
+ def transformer = new TestInjectTransformer(Runnable, runnable)
def mgr = createMgr (transformer, {
goHandle = findHandle (it, "go")
@@ -38,7 +36,7 @@ class SimpleClassLoading extends Abstrac
1 * runnable.run()
- concreteClass != instance.class
+ concreteClass != instance
}
def "field transformation in subclass of transformed class"() {
@@ -46,12 +44,12 @@ class SimpleClassLoading extends Abstrac
def goHandle
def callHandle
- def runnable = Mock(Runnable.class)
- def callable = Mock(Callable.class)
+ def runnable = Mock(Runnable)
+ def callable = Mock(Callable)
def mgr = createMgr (
- new TestInjectTransformer(Runnable.class, runnable),
- new TestInjectTransformer(Callable.class, callable), {
+ new TestInjectTransformer(Runnable, runnable),
+ new TestInjectTransformer(Callable, callable), {
if (goHandle ==null) goHandle = findHandle (it, "go")
if (callHandle == null) callHandle = findHandle(it, "call")
Modified: tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/StaticFieldAccess.groovy
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/StaticFieldAccess.groovy?rev=1308540&r1=1308539&r2=1308540&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/StaticFieldAccess.groovy (original)
+++ tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/StaticFieldAccess.groovy Mon Apr 2 20:37:37 2012
@@ -9,17 +9,17 @@ class StaticFieldAccess extends Abstract
setup:
def pc = mgr.getPlasticClass("testsubjects.StaticFieldHolder")
- pc.introduceInterface(Access.class)
+ pc.introduceInterface(Access)
pc.introduceMethod(new MethodDescription("java.lang.Object", "read")).changeImplementation({
InstructionBuilder b ->
- b.getStaticField("testsubjects.StaticFieldHolder", "VALUE", String.class).returnResult()
+ b.getStaticField("testsubjects.StaticFieldHolder", "VALUE", String).returnResult()
} as InstructionBuilderCallback)
pc.introduceMethod(new MethodDescription("void", "write", "java.lang.Object")).changeImplementation({
InstructionBuilder b ->
- b.loadArgument(0).checkcast(String.class)
- b.putStaticField("testsubjects.StaticFieldHolder", "VALUE", String.class).returnResult()
+ b.loadArgument(0).checkcast(String)
+ b.putStaticField("testsubjects.StaticFieldHolder", "VALUE", String).returnResult()
} as InstructionBuilderCallback)
Access o = pc.createInstantiator().newInstance()
Modified: tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ToStringTests.groovy
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ToStringTests.groovy?rev=1308540&r1=1308539&r2=1308540&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ToStringTests.groovy (original)
+++ tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/ToStringTests.groovy Mon Apr 2 20:37:37 2012
@@ -1,7 +1,6 @@
package org.apache.tapestry5.plastic
import org.apache.tapestry5.internal.plastic.StandardDelegate
-
import testsubjects.HasToString
class ToStringTests extends AbstractPlasticSpecification {
@@ -11,7 +10,7 @@ class ToStringTests extends AbstractPlas
def mgr = PlasticManager.withContextClassLoader().create()
- def o = mgr.createClass (Object.class, {
+ def o = mgr.createClass (Object, {
it.addToString "<ToString>" } as PlasticClassTransformer).newInstance()
expect:
@@ -26,7 +25,7 @@ class ToStringTests extends AbstractPlas
def mgr = PlasticManager.withContextClassLoader().delegate(new StandardDelegate()).packages(["testsubjects"]).create()
- def o = mgr.createClass (HasToString.class, { it.addToString "<OverrideToString>" } as PlasticClassTransformer).newInstance()
+ def o = mgr.createClass (HasToString, { it.addToString "<OverrideToString>" } as PlasticClassTransformer).newInstance()
expect: