Example usage for org.springframework.beans NotWritablePropertyException getBeanClass

List of usage examples for org.springframework.beans NotWritablePropertyException getBeanClass

Introduction

In this page you can find the example usage for org.springframework.beans NotWritablePropertyException getBeanClass.

Prototype

public Class<?> getBeanClass() 

Source Link

Document

Return the offending bean class.

Usage

From source file:org.springframework.beans.AbstractPropertyAccessorTests.java

@Test
public void setUnknownProperty() {
    Simple target = new Simple("John", 2);
    AbstractPropertyAccessor accessor = createAccessor(target);

    try {// w  ww. j a  va  2s . co m
        accessor.setPropertyValue("name1", "value");
        fail("Should have failed to set an unknown property.");
    } catch (NotWritablePropertyException e) {
        assertEquals(Simple.class, e.getBeanClass());
        assertEquals("name1", e.getPropertyName());
        assertEquals("Invalid number of possible matches", 1, e.getPossibleMatches().length);
        assertEquals("name", e.getPossibleMatches()[0]);
    }
}

From source file:org.springframework.beans.AbstractPropertyAccessorTests.java

@Test
public void setUnknownPropertyWithPossibleMatches() {
    Simple target = new Simple("John", 2);
    AbstractPropertyAccessor accessor = createAccessor(target);

    try {/*from   w w  w .j  a v  a2s. co  m*/
        accessor.setPropertyValue("foo", "value");
        fail("Should have failed to set an unknown property.");
    } catch (NotWritablePropertyException e) {
        assertEquals(Simple.class, e.getBeanClass());
        assertEquals("foo", e.getPropertyName());
    }
}