List of usage examples for org.springframework.beans NullValueInNestedPathException getPropertyName
public String getPropertyName()
From source file:org.obiba.magma.beans.BeanPropertyVariableValueSource.java
@Nullable protected Object getPropertyValue(String propertyPath, BeanWrapper bw) { try {/*w w w.jav a2 s. c o m*/ return bw.getPropertyValue(propertyPath); } catch (NullValueInNestedPathException e) { return null; } catch (InvalidPropertyException e) { throw new MagmaRuntimeException("Invalid definition of variable " + getVariable().getName() + ". Cannot obtain value for property '" + e.getPropertyName() + "' on bean of class " + e.getBeanClass(), e); } }
From source file:net.sf.juffrou.reflect.spring.BeanWrapperTests.java
@Test public void testSetNestedPropertyNullValue() throws Exception { ITestBean rod = new TestBean("rod", 31); BeanWrapper bw = new JuffrouSpringBeanWrapper(rod); try {//from ww w.jav a2 s. c o m bw.setPropertyValue("spouse.age", new Integer(31)); fail("Shouldn't have succeeded with null path"); } catch (NullValueInNestedPathException ex) { // expected assertTrue("it was the spouse property that was null, not " + ex.getPropertyName(), ex.getPropertyName().equals("spouse")); } }
From source file:net.sf.juffrou.reflect.spring.BeanWrapperTests.java
@Test public void testGetNestedPropertyNullValue() throws Exception { ITestBean rod = new TestBean("rod", 31); ITestBean kerry = new TestBean("kerry", 35); rod.setSpouse(kerry);/*from w w w. j ava2s . co m*/ BeanWrapper bw = new JuffrouSpringBeanWrapper(rod); try { bw.getPropertyValue("spouse.spouse.age"); fail("Shouldn't have succeded with null path"); } catch (NullValueInNestedPathException ex) { // ok assertTrue("it was the spouse.spouse property that was null, not " + ex.getPropertyName(), ex.getPropertyName().equals("spouse.spouse")); } }
From source file:org.springframework.beans.AbstractPropertyAccessorTests.java
@Test public void getPropertyIntermediatePropertyIsNull() { Person target = createPerson("John", "London", "UK"); target.address = null;// w ww . j a va 2s .c om AbstractPropertyAccessor accessor = createAccessor(target); try { accessor.getPropertyValue("address.country.name"); fail("Should have failed to get value with null intermediate path"); } catch (NullValueInNestedPathException e) { assertEquals("address", e.getPropertyName()); assertEquals(Person.class, e.getBeanClass()); } }
From source file:org.springframework.beans.AbstractPropertyAccessorTests.java
@Test public void setPropertyIntermediatePropertyIsNull() { Person target = createPerson("John", "Paris", "FR"); target.address.country = null;/*ww w .j a v a2 s .co m*/ AbstractPropertyAccessor accessor = createAccessor(target); try { accessor.setPropertyValue("address.country.name", "UK"); fail("Should have failed to set value with intermediate null value"); } catch (NullValueInNestedPathException e) { assertEquals("address.country", e.getPropertyName()); assertEquals(Person.class, e.getBeanClass()); } assertThat(target.address.country, is(nullValue())); // Not touched }
From source file:org.springframework.beans.AbstractPropertyAccessorTests.java
@Test public void setAnotherPropertyIntermediatePropertyIsNull() throws Exception { ITestBean target = new TestBean("rod", 31); AbstractPropertyAccessor accessor = createAccessor(target); try {/*from w w w . java 2 s . co m*/ accessor.setPropertyValue("spouse.age", new Integer(31)); fail("Shouldn't have succeeded with null path"); } catch (NullValueInNestedPathException ex) { // expected assertTrue("it was the spouse property that was null, not " + ex.getPropertyName(), ex.getPropertyName().equals("spouse")); } }
From source file:org.springframework.beans.BeanWrapperTests.java
@Test public void testGetNestedPropertyNullValue() throws Exception { ITestBean rod = new TestBean("rod", 31); ITestBean kerry = new TestBean("kerry", 35); rod.setSpouse(kerry);/*from w w w . ja v a 2 s . co m*/ BeanWrapper bw = new BeanWrapperImpl(rod); try { bw.getPropertyValue("spouse.spouse.age"); fail("Shouldn't have succeded with null path"); } catch (NullValueInNestedPathException ex) { // ok assertTrue("it was the spouse.spouse property that was null, not " + ex.getPropertyName(), ex.getPropertyName().equals("spouse.spouse")); } }
From source file:org.springframework.beans.BeanWrapperTests.java
@Test public void testSetNestedPropertyNullValue() throws Exception { ITestBean rod = new TestBean("rod", 31); BeanWrapper bw = new BeanWrapperImpl(rod); try {/*w w w. ja va 2 s . co m*/ bw.setPropertyValue("spouse.age", new Integer(31)); fail("Shouldn't have succeeded with null path"); } catch (NullValueInNestedPathException ex) { // expected assertTrue("it was the spouse property that was null, not " + ex.getPropertyName(), ex.getPropertyName().equals("spouse")); } }