001 package org.springframework.binding.form.support; 002 003 import junit.framework.TestCase; 004 005 import org.springframework.binding.PropertyAccessStrategy; 006 import org.springframework.binding.PropertyMetadataAccessStrategy; 007 import org.springframework.binding.support.TestBean; 008 009 010 public class FormModelPropertyAccessStrategyTests extends TestCase 011 { 012 013 protected AbstractFormModel getFormModel(Object formObject) 014 { 015 return new TestAbstractFormModel(formObject); 016 } 017 018 /** 019 * Test to ensure that the AccessStrategy works correctly with writeable/readable properties. * 020 */ 021 public void testReadOnlyPropertyAccess() 022 { 023 AbstractFormModel model = getFormModel(new TestBean()); 024 PropertyAccessStrategy propertyAccessStrategy = model.getPropertyAccessStrategy(); 025 PropertyMetadataAccessStrategy metaDataAccessStrategy = propertyAccessStrategy.getMetadataAccessStrategy(); 026 027 assertFalse("Property is readonly, isWriteable() should return false.", metaDataAccessStrategy.isWriteable("readOnly")); 028 assertTrue("Property is readonly, isReadable() should return true.", metaDataAccessStrategy.isReadable("readOnly")); 029 } 030 }