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 2009/04/28 18:53:28 UTC

svn commit: r769459 - in /tapestry/tapestry5/trunk/tapestry-core/src: main/java/org/apache/tapestry5/beaneditor/BeanModel.java test/java/org/apache/tapestry5/internal/services/BeanModelSourceImplTest.java

Author: hlship
Date: Tue Apr 28 16:53:27 2009
New Revision: 769459

URL: http://svn.apache.org/viewvc?rev=769459&view=rev
Log:
TAP5-668: BeanModel documentation should be more clear that a property must exist when using add(String).

Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/beaneditor/BeanModel.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BeanModelSourceImplTest.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/beaneditor/BeanModel.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/beaneditor/BeanModel.java?rev=769459&r1=769458&r2=769459&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/beaneditor/BeanModel.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/beaneditor/BeanModel.java Tue Apr 28 16:53:27 2009
@@ -1,4 +1,4 @@
-// Copyright 2007, 2008 The Apache Software Foundation
+// Copyright 2007, 2008, 2009 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.
@@ -70,7 +70,9 @@
 
     /**
      * Adds a new property to the model, returning its mutable model for further refinement. The property is added to
-     * the <em>end</em> of the list of properties.
+     * the <em>end</em> of the list of properties. The property must be real (but may have been excluded if there was no
+     * {@linkplain org.apache.tapestry5.beaneditor.DataType datatype} associated with the property). To add a synthetic
+     * property, use {@link #add(String, org.apache.tapestry5.PropertyConduit)}
      *
      * @param propertyName name of property to add
      * @return the new property model (for further configuration)
@@ -79,7 +81,7 @@
     PropertyModel add(String propertyName);
 
     /**
-     * Adds a new property to the model, ordered before or after an existing property.
+     * Adds a new property to the model (as with {@link #add(String)}), ordered before or after an existing property.
      *
      * @param position             controls whether the new property is ordered before or after the existing property
      * @param existingPropertyName the name of an existing property (this must exist)
@@ -104,7 +106,7 @@
                       PropertyConduit conduit);
 
     /**
-     * Adds a new property to the model, returning its mutable model for further refinement.
+     * Adds a new, synthetic property to the model, returning its mutable model for further refinement.
      *
      * @param propertyName name of property to add
      * @param conduit      the conduit used to read or update the property; this may be null for a synthetic or

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BeanModelSourceImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BeanModelSourceImplTest.java?rev=769459&r1=769458&r2=769459&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BeanModelSourceImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BeanModelSourceImplTest.java Tue Apr 28 16:53:27 2009
@@ -1,4 +1,4 @@
-// Copyright 2007, 2008 The Apache Software Foundation
+// Copyright 2007, 2008, 2009 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.
@@ -460,7 +460,7 @@
 
         assertSame(propertyModel.getPropertyType(), String[].class);
 
-        String[] value = {"foo", "bar"};
+        String[] value = { "foo", "bar" };
 
         StringArrayBean bean = new StringArrayBean();
 
@@ -554,6 +554,30 @@
     }
 
     @Test
+    public void add_missing_property_is_failure()
+    {
+        Messages messages = mockMessages();
+
+        stub_contains(messages, false);
+
+        replay();
+
+        BeanModel model = source.create(SimpleBean.class, true, messages);
+
+        try
+        {
+            model.add("doesNotExist");
+            unreachable();
+        }
+        catch (PropertyExpressionException ex)
+        {
+            assertMessageContains(ex, "does not contain a property named 'doesNotExist'");
+        }
+
+        verify();
+    }
+
+    @Test
     public void exclude_property()
     {
         Messages messages = mockMessages();