001 /*
002 * Copyright 2007 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005 * use this file except in compliance with the License. You may obtain a copy of
006 * the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013 * License for the specific language governing permissions and limitations under
014 * the License.
015 */
016 package org.springframework.binding.support;
017
018 import java.util.List;
019 import java.util.Map;
020
021 import org.springframework.binding.PropertyMetadataAccessStrategy;
022
023 /**
024 * @author Arne Limburg
025 */
026 public class ClassPropertyAccessStrategyTests extends AbstractPropertyAccessStrategyTests {
027
028 protected AbstractPropertyAccessStrategy createPropertyAccessStrategy(Object target) {
029 return new ClassPropertyAccessStrategy(target.getClass());
030 }
031
032 protected boolean isStrictNullHandlingEnabled() {
033 return false;
034 }
035
036 protected void doSetUp() throws Exception {
037 super.doSetUp();
038 pas.getDomainObjectHolder().setValue(testBean);
039 }
040
041 /**
042 * Test the metadata on type/readability/writeability.
043 */
044 public void testMetaData() {
045 PropertyMetadataAccessStrategy mas = pas.getMetadataAccessStrategy();
046
047 assertPropertyMetadata(mas, "simpleProperty", String.class, true, true);
048 assertPropertyMetadata(mas, "mapProperty", Map.class, true, true);
049 assertPropertyMetadata(mas, "listProperty", List.class, true, true);
050 assertPropertyMetadata(mas, "readOnly", Object.class, true, false);
051 assertPropertyMetadata(mas, "writeOnly", Object.class, false, true);
052
053 // type/readable/writeable depend not on the property being not null
054 assertPropertyMetadata(mas, "nestedProperty.simpleProperty", String.class, true, true);
055
056 }
057
058 public void testBeanThatImplementsPropertyChangePublisher() {
059 pas = new ClassPropertyAccessStrategy(TestBeanWithPCP.class);
060 super.testBeanThatImplementsPropertyChangePublisher();
061 }
062 }