You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2012/01/24 18:27:32 UTC

svn commit: r1235365 - in /tapestry/tapestry5/branches/5.3: plastic/src/test/groovy/org/apache/tapestry5/plastic/ plastic/src/test/java/testsubjects/ tapestry-core/src/test/java/org/apache/tapestry5/internal/services/

Author: hlship
Date: Tue Jan 24 17:27:32 2012
New Revision: 1235365

URL: http://svn.apache.org/viewvc?rev=1235365&view=rev
Log:
Add more missing files copied from the trunk branch

Added:
    tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldAccessTests.groovy
    tapestry/tapestry5/branches/5.3/plastic/src/test/java/testsubjects/ProtectedField.java
    tapestry/tapestry5/branches/5.3/plastic/src/test/java/testsubjects/ProtectedFieldCollaborator.java
    tapestry/tapestry5/branches/5.3/plastic/src/test/java/testsubjects/PublicInstanceField.java
    tapestry/tapestry5/branches/5.3/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BeanWithStaticField.java

Added: 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=1235365&view=auto
==============================================================================
--- tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldAccessTests.groovy (added)
+++ tapestry/tapestry5/branches/5.3/plastic/src/test/groovy/org/apache/tapestry5/plastic/FieldAccessTests.groovy Tue Jan 24 17:27:32 2012
@@ -0,0 +1,77 @@
+package org.apache.tapestry5.plastic
+
+import testannotations.KindaInject
+import testannotations.SimpleAnnotation
+
+/**
+ *  Tests related to access to non-private fields between transformed classes (a new feature in 5.4).
+ */
+class FieldAccessTests extends AbstractPlasticSpecification
+{
+    def "access protected field from other transformed class"()
+    {
+        FieldConduit fc = Mock()
+
+        PlasticClass pc = mgr.getPlasticClass("testsubjects.ProtectedField")
+
+        pc.allFields.first().setConduit(fc)
+
+        def delegate = pc.createInstantiator().newInstance()
+
+        pc = mgr.getPlasticClass("testsubjects.ProtectedFieldCollaborator")
+
+        pc.allFields.first().inject(delegate)
+
+        def collab = pc.createInstantiator().newInstance()
+
+        when:
+
+        collab.setProtectedValue("gloop")
+
+        then:
+
+        1 * fc.set(_, _, "gloop")
+
+
+        when:
+
+        fc.get(_, _) >> "badoop"
+
+        then:
+
+        collab.getProtectedValue() == "badoop"
+    }
+
+    def "access protected field from inner class"()
+    {
+
+        FieldConduit fc = Mock()
+
+        def delegate
+
+        PlasticClassTransformer installFieldConduit = {     PlasticClass pc ->
+
+            pc.getFieldsWithAnnotation(SimpleAnnotation.class).each { f -> f.setConduit(fc) }
+
+        } as PlasticClassTransformer
+
+        PlasticClassTransformer handleInjection = { PlasticClass pc ->
+
+            pc.getFieldsWithAnnotation(KindaInject.class).each { f -> f.inject(delegate) }
+        } as PlasticClassTransformer
+
+        def mgr = createMgr(installFieldConduit, handleInjection)
+
+        delegate = mgr.getClassInstantiator("testsubjects.ProtectedField").newInstance()
+
+        def collab = mgr.getClassInstantiator("testsubjects.ProtectedFieldCollaborator").newInstance()
+
+        when:
+
+        fc.get(_, _) >> "gnip"
+
+        then:
+
+        collab.valueGetter.value == "gnip"
+    }
+}

Added: tapestry/tapestry5/branches/5.3/plastic/src/test/java/testsubjects/ProtectedField.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/plastic/src/test/java/testsubjects/ProtectedField.java?rev=1235365&view=auto
==============================================================================
--- tapestry/tapestry5/branches/5.3/plastic/src/test/java/testsubjects/ProtectedField.java (added)
+++ tapestry/tapestry5/branches/5.3/plastic/src/test/java/testsubjects/ProtectedField.java Tue Jan 24 17:27:32 2012
@@ -0,0 +1,12 @@
+package testsubjects;
+
+import testannotations.SimpleAnnotation;
+
+/**
+ * Used to test access to protected fields. Accessed from {@link ProtectedFieldCollaborator}.
+ */
+public class ProtectedField
+{
+    @SimpleAnnotation
+    protected String protectedValue;
+}

Added: tapestry/tapestry5/branches/5.3/plastic/src/test/java/testsubjects/ProtectedFieldCollaborator.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/plastic/src/test/java/testsubjects/ProtectedFieldCollaborator.java?rev=1235365&view=auto
==============================================================================
--- tapestry/tapestry5/branches/5.3/plastic/src/test/java/testsubjects/ProtectedFieldCollaborator.java (added)
+++ tapestry/tapestry5/branches/5.3/plastic/src/test/java/testsubjects/ProtectedFieldCollaborator.java Tue Jan 24 17:27:32 2012
@@ -0,0 +1,31 @@
+package testsubjects;
+
+import testannotations.KindaInject;
+import testinterfaces.ValueGetter;
+
+public class ProtectedFieldCollaborator
+{
+    @KindaInject
+    ProtectedField delegate;
+
+    public String getProtectedValue()
+    {
+        return delegate.protectedValue;
+    }
+
+    public void setProtectedValue(String newValue)
+    {
+        delegate.protectedValue = newValue;
+    }
+
+    public ValueGetter getValueGetter()
+    {
+        return new ValueGetter()
+        {
+            public String getValue()
+            {
+                return delegate.protectedValue;
+            }
+        };
+    }
+}

Added: tapestry/tapestry5/branches/5.3/plastic/src/test/java/testsubjects/PublicInstanceField.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/plastic/src/test/java/testsubjects/PublicInstanceField.java?rev=1235365&view=auto
==============================================================================
--- tapestry/tapestry5/branches/5.3/plastic/src/test/java/testsubjects/PublicInstanceField.java (added)
+++ tapestry/tapestry5/branches/5.3/plastic/src/test/java/testsubjects/PublicInstanceField.java Tue Jan 24 17:27:32 2012
@@ -0,0 +1,20 @@
+// 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 testsubjects;
+
+public class PublicInstanceField
+{
+    public String publicNotAllowed;
+}

Added: tapestry/tapestry5/branches/5.3/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BeanWithStaticField.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BeanWithStaticField.java?rev=1235365&view=auto
==============================================================================
--- tapestry/tapestry5/branches/5.3/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BeanWithStaticField.java (added)
+++ tapestry/tapestry5/branches/5.3/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BeanWithStaticField.java Tue Jan 24 17:27:32 2012
@@ -0,0 +1,8 @@
+package org.apache.tapestry5.internal.services;
+
+public class BeanWithStaticField
+{
+    public static final String DEFAULT_NAME = "Joe";
+
+    public String name = DEFAULT_NAME;
+}