tapestry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r602686 - in /tapestry/tapestry5/trunk/tapestry-core/src: main/java/org/apache/tapestry/internal/services/ main/resources/org/apache/tapestry/internal/services/ test/java/org/apache/tapestry/internal/services/
Date Sun, 09 Dec 2007 15:40:22 GMT
Author: hlship
Date: Sun Dec  9 07:40:19 2007
New Revision: 602686

URL: http://svn.apache.org/viewvc?rev=602686&view=rev
Log:
TAPESTRY-1966: Non-private/non-static fields in a page should be an exception, not a warning

Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalClassTransformationImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/internal/services/ServicesStrings.properties
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/InternalClassTransformationImplTest.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalClassTransformationImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalClassTransformationImpl.java?rev=602686&r1=602685&r2=602686&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalClassTransformationImpl.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalClassTransformationImpl.java
Sun Dec  9 07:40:19 2007
@@ -230,7 +230,7 @@
         addMemberNames(_ctClass.getDeclaredMethods());
     }
 
-    public void verifyFields()
+    void verifyFields()
     {
         List<String> names = newList();
 
@@ -249,12 +249,7 @@
             names.add(name);
         }
 
-        if (!names.isEmpty())
-        {
-            Collections.sort(names);
-
-            _logger.error(ServicesMessages.nonPrivateFields(getClassName(), names));
-        }
+        if (!names.isEmpty()) throw new RuntimeException(ServicesMessages.nonPrivateFields(getClassName(),
names));
     }
 
     private void addMemberNames(CtMember[] members)

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/internal/services/ServicesStrings.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/internal/services/ServicesStrings.properties?rev=602686&r1=602685&r2=602686&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/internal/services/ServicesStrings.properties
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/internal/services/ServicesStrings.properties
Sun Dec  9 07:40:19 2007
@@ -31,8 +31,7 @@
 method-compile-error=Error compiling method %s (%s): %s
 render-queue-error=Render queue error in %s: %s
 read-only-field=Field %s.%s is read-only.
-non-private-fields=Class %s contains field(s) (%s) that are not private. Tapestry will ignore
these fields, even if they \
-  have annotations. Runtime behavior, especially in production, may not be what you expect.
\
+non-private-fields=Class %s contains field(s) (%s) that are not private. \
   You should change these fields to private, and add accessor methods if needed.  
 mixins-invalid-without-id-or-type=You may not specify mixins for element <%s> because
it does not represent a component (which requires either an id attribute or a type attribute).
 comp-type-conflict=Embedded component '%s' provides a type attribute in the template ('%s')
as well as in the component class ('%s'). \

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/InternalClassTransformationImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/InternalClassTransformationImplTest.java?rev=602686&r1=602685&r2=602686&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/InternalClassTransformationImplTest.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/InternalClassTransformationImplTest.java
Sun Dec  9 07:40:19 2007
@@ -41,7 +41,6 @@
 import java.lang.annotation.Target;
 import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
-import java.util.Arrays;
 import static java.util.Arrays.asList;
 import java.util.List;
 import java.util.Map;
@@ -919,33 +918,27 @@
     }
 
     @Test
-    public void non_private_fields_log_an_error() throws Exception
+    public void non_private_fields_are_an_exception() throws Exception
     {
         Logger logger = mockLogger();
 
-        logger.error(ServicesMessages.nonPrivateFields(VisibilityBean.class.getName(), Arrays
-                .asList("_$myPackagePrivate", "_$myProtected", "_$myPublic")));
 
         replay();
 
         InternalClassTransformation ct = createClassTransformation(VisibilityBean.class,
logger);
 
-        List<String> names = ct.findFieldsWithAnnotation(Retain.class);
-
-        // Only _myLong shows up, because its the only private field
-
-        assertEquals(names, Arrays.asList("_$myLong"));
-
-        // However, all the fields are "reserved" via the IdAllocator ...
-
-        assertEquals(ct.newMemberName("_$myLong"), "_$myLong_0");
-        assertEquals(ct.newMemberName("_$myStatic"), "_$myStatic_0");
-        assertEquals(ct.newMemberName("_$myProtected"), "_$myProtected_0");
+        try
+        {
 
-        // The check for non-private fields has been moved from the ICTI constructor to the
finish
-        // method.
+            ct.finish();
 
-        ct.finish();
+            unreachable();
+        }
+        catch (RuntimeException ex)
+        {
+            assertMessageContains(ex, "Class " + VisibilityBean.class.getName() + " contains
field(s)",
+                                  "_$myPackagePrivate", "_$myProtected", "_$myPublic");
+        }
 
         verify();
     }



Mime
View raw message