1   package org.springframework.binding.form.support;
2   
3   import junit.framework.TestCase;
4   
5   import org.springframework.binding.PropertyAccessStrategy;
6   import org.springframework.binding.PropertyMetadataAccessStrategy;
7   import org.springframework.binding.support.TestBean;
8   
9   
10  public class FormModelPropertyAccessStrategyTests extends TestCase
11  {
12  
13      protected AbstractFormModel getFormModel(Object formObject) 
14      {
15          return new TestAbstractFormModel(formObject);
16      }
17      
18      /**
19       * Test to ensure that the AccessStrategy works correctly with writeable/readable properties.     *
20       */
21      public void testReadOnlyPropertyAccess()
22      {
23          AbstractFormModel model = getFormModel(new TestBean());
24          PropertyAccessStrategy propertyAccessStrategy = model.getPropertyAccessStrategy();
25          PropertyMetadataAccessStrategy metaDataAccessStrategy = propertyAccessStrategy.getMetadataAccessStrategy();
26  
27          assertFalse("Property is readonly, isWriteable() should return false.", metaDataAccessStrategy.isWriteable("readOnly"));
28          assertTrue("Property is readonly, isReadable() should return true.", metaDataAccessStrategy.isReadable("readOnly"));
29      }
30  }