Package org.springframework.binding

Examples of org.springframework.binding.PropertyMetadataAccessStrategy


* @since May 8, 2006 5:20:39 PM
*/
public class AnnotationAwareBeanPropertyAccessStrategyTests extends SpringRichTestCase {
    public void testBeanWithNoAnnotations() {
        final AnnotationAwareBeanPropertyAccessStrategy pas = new AnnotationAwareBeanPropertyAccessStrategy(new NoAnnotationTestBean());
        final PropertyMetadataAccessStrategy mas = pas.getMetadataAccessStrategy();
       
        Map<String,Object> um = mas.getAllUserMetadata("name");
        assertTrue(um == null || um.size() == 0);
        um = mas.getAllUserMetadata("age");
        assertTrue(um == null || um.size() == 0);
        um = mas.getAllUserMetadata("rank");
        assertTrue(um == null || um.size() == 0);
    }
View Full Code Here


        assertTrue(um == null || um.size() == 0);
    }
   
    public void testBeanWithAnnotations() throws Exception {
        final AnnotationAwareBeanPropertyAccessStrategy pas = new AnnotationAwareBeanPropertyAccessStrategy(new TestBean());
        final PropertyMetadataAccessStrategy mas = pas.getMetadataAccessStrategy();
       
        Map<String,Object> um = mas.getAllUserMetadata("name");
        assertNotNull(um);
        assertEquals(2, um.size());
        assertEquals(Boolean.TRUE, um.get("org.springframework.binding.support.NoValueAnnotation"));
        NoValueAnnotation nva = (NoValueAnnotation)um.get("@" + NoValueAnnotation.class.getName());
        assertNotNull(nva);
       
        um = mas.getAllUserMetadata("age");
        assertNotNull(um);
        assertEquals(4, um.size());
        assertEquals(Boolean.TRUE, um.get("org.springframework.binding.support.NoValueAnnotation"));
        assertEquals("The Age Method", um.get("org.springframework.binding.support.SingleValueAnnotation"));
        nva = (NoValueAnnotation)um.get("@" + NoValueAnnotation.class.getName());
        assertNotNull(nva);
        SingleValueAnnotation sva = (SingleValueAnnotation)um.get("@" + SingleValueAnnotation.class.getName());
        assertNotNull(sva);
        assertEquals("The Age Method", sva.value());
       
        um = mas.getAllUserMetadata("rank");
        assertNotNull(um);
        assertEquals(9, um.size());
        assertEquals(Boolean.TRUE, um.get("org.springframework.binding.support.NoValueAnnotation"));
        assertEquals("The Rank Method", um.get("org.springframework.binding.support.SingleValueAnnotation"));
        assertEquals(Boolean.TRUE, um.get("org.springframework.binding.support.MultiValueAnnotation"));
        assertEquals("First Test Name", um.get("org.springframework.binding.support.MultiValueAnnotation.name"));
        assertEquals(24.5, um.get("org.springframework.binding.support.MultiValueAnnotation.age"));
        assertEquals(10, um.get("org.springframework.binding.support.MultiValueAnnotation.rank"));
        nva = (NoValueAnnotation)um.get("@" + NoValueAnnotation.class.getName());
        assertNotNull(nva);
        sva = (SingleValueAnnotation)um.get("@" + SingleValueAnnotation.class.getName());
        assertNotNull(sva);
        assertEquals("The Rank Method", sva.value());
        MultiValueAnnotation mva = (MultiValueAnnotation)um.get("@" + MultiValueAnnotation.class.getName());
        assertNotNull(mva);
        assertEquals("First Test Name", mva.name());
        assertEquals(24.5, mva.age());
        assertEquals(10, mva.rank());
       
        um = mas.getAllUserMetadata("description");
        assertTrue(um == null || um.size() == 0);
    }
View Full Code Here

    /**
     * Test the metadata on type/readability/writeability.
     */
    public void testMetaData() {
        PropertyMetadataAccessStrategy mas = pas.getMetadataAccessStrategy();

        assertPropertyMetadata(mas, "simpleProperty", String.class, true, true);
        assertPropertyMetadata(mas, "mapProperty", Map.class, true, true);
        assertPropertyMetadata(mas, "listProperty", List.class, true, true);
        assertPropertyMetadata(mas, "readOnly", Object.class, true, false);
View Full Code Here

  /**
   * Test the metadata on type/readability/writeability.
   */
  public void testMetaData() {
    PropertyMetadataAccessStrategy mas = pas.getMetadataAccessStrategy();

    assertPropertyMetadata(mas, "simpleProperty", String.class, true, true);
    assertPropertyMetadata(mas, "mapProperty", Map.class, true, true);
    assertPropertyMetadata(mas, "listProperty", List.class, true, true);
    assertPropertyMetadata(mas, "readOnly", Object.class, true, false);
View Full Code Here

    // formProperty + "' already exists.");
    if (valueModel instanceof BufferedValueModel) {
      ((BufferedValueModel) valueModel).setCommitTrigger(commitTrigger);
    }

    PropertyMetadataAccessStrategy metadataAccessStrategy = getFormObjectPropertyAccessStrategy()
        .getMetadataAccessStrategy();

    FormModelMediatingValueModel mediatingValueModel = new FormModelMediatingValueModel(valueModel,
        metadataAccessStrategy.isWriteable(formProperty));
    mediatingValueModels.put(formProperty, mediatingValueModel);

    FieldMetadata metadata = new DefaultFieldMetadata(this, mediatingValueModel, metadataAccessStrategy
        .getPropertyType(formProperty), !metadataAccessStrategy.isWriteable(formProperty),
        metadataAccessStrategy.getAllUserMetadata(formProperty));
    metadata.addPropertyChangeListener(FieldMetadata.DIRTY_PROPERTY, childStateChangeHandler);
    return add(formProperty, mediatingValueModel, metadata);
  }
View Full Code Here

    /**
     * Test the metadata on type/readability/writeability.
     */
    public void testMetaData() {
        PropertyMetadataAccessStrategy mas = pas.getMetadataAccessStrategy();

        assertPropertyMetadata(mas, "simpleProperty", String.class, true, true);
        assertPropertyMetadata(mas, "mapProperty", Map.class, true, true);
        assertPropertyMetadata(mas, "listProperty", List.class, true, true);
        assertPropertyMetadata(mas, "readOnly", Object.class, true, false);
View Full Code Here

     */
    public void testReadOnlyPropertyAccess()
    {
        AbstractFormModel model = getFormModel(new TestBean());
        PropertyAccessStrategy propertyAccessStrategy = model.getPropertyAccessStrategy();
        PropertyMetadataAccessStrategy metaDataAccessStrategy = propertyAccessStrategy.getMetadataAccessStrategy();

        assertFalse("Property is readonly, isWriteable() should return false.", metaDataAccessStrategy.isWriteable("readOnly"));
        assertTrue("Property is readonly, isReadable() should return true.", metaDataAccessStrategy.isReadable("readOnly"));
    }
View Full Code Here

TOP

Related Classes of org.springframework.binding.PropertyMetadataAccessStrategy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.