1   /*
2    * Copyright 2007 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5    * use this file except in compliance with the License. You may obtain a copy of
6    * the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations under
14   * the License.
15   */
16  package org.springframework.binding.support;
17  
18  import java.util.List;
19  import java.util.Map;
20  
21  import org.springframework.binding.PropertyMetadataAccessStrategy;
22  
23  /**
24   * @author Arne Limburg
25   */
26  public class ClassPropertyAccessStrategyTests extends AbstractPropertyAccessStrategyTests {
27  
28  	protected AbstractPropertyAccessStrategy createPropertyAccessStrategy(Object target) {
29  		return new ClassPropertyAccessStrategy(target.getClass());
30  	}
31  
32  	protected boolean isStrictNullHandlingEnabled() {
33  		return false;
34  	}
35  
36  	protected void doSetUp() throws Exception {
37  		super.doSetUp();
38  		pas.getDomainObjectHolder().setValue(testBean);
39  	}
40  
41  	/**
42  	 * Test the metadata on type/readability/writeability.
43  	 */
44  	public void testMetaData() {
45  		PropertyMetadataAccessStrategy mas = pas.getMetadataAccessStrategy();
46  
47  		assertPropertyMetadata(mas, "simpleProperty", String.class, true, true);
48  		assertPropertyMetadata(mas, "mapProperty", Map.class, true, true);
49  		assertPropertyMetadata(mas, "listProperty", List.class, true, true);
50  		assertPropertyMetadata(mas, "readOnly", Object.class, true, false);
51  		assertPropertyMetadata(mas, "writeOnly", Object.class, false, true);
52  
53  		// type/readable/writeable depend not on the property being not null
54  		assertPropertyMetadata(mas, "nestedProperty.simpleProperty", String.class, true, true);
55  
56  	}
57  
58  	public void testBeanThatImplementsPropertyChangePublisher() {
59  		pas = new ClassPropertyAccessStrategy(TestBeanWithPCP.class);
60  		super.testBeanThatImplementsPropertyChangePublisher();
61  	}
62  }