use of cn.taketoday.expression.spel.support.ReflectivePropertyAccessor in project today-infrastructure by TAKETODAY.
the class SpelReproTests method propertyAccessOnNullTarget_SPR5663.
@Test
void propertyAccessOnNullTarget_SPR5663() throws AccessException {
PropertyAccessor accessor = new ReflectivePropertyAccessor();
EvaluationContext context = TestScenarioCreator.getTestEvaluationContext();
assertThat(accessor.canRead(context, null, "abc")).isFalse();
assertThat(accessor.canWrite(context, null, "abc")).isFalse();
assertThatIllegalStateException().isThrownBy(() -> accessor.read(context, null, "abc"));
assertThatIllegalStateException().isThrownBy(() -> accessor.write(context, null, "abc", "foo"));
}
use of cn.taketoday.expression.spel.support.ReflectivePropertyAccessor in project today-infrastructure by TAKETODAY.
the class SpelReproTests method SPR9994_bridgeMethods.
@Test
void SPR9994_bridgeMethods() throws Exception {
ReflectivePropertyAccessor accessor = new ReflectivePropertyAccessor();
StandardEvaluationContext context = new StandardEvaluationContext();
GenericImplementation target = new GenericImplementation();
accessor.write(context, target, "property", "1");
assertThat(target.value).isEqualTo(1);
TypedValue value = accessor.read(context, target, "property");
assertThat(value.getValue()).isEqualTo(1);
assertThat(value.getTypeDescriptor().getType()).isEqualTo(Integer.class);
assertThat(value.getTypeDescriptor().getAnnotations()).isNotEmpty();
}
use of cn.taketoday.expression.spel.support.ReflectivePropertyAccessor in project today-framework by TAKETODAY.
the class SpelReproTests method SPR9994_bridgeMethods.
@Test
void SPR9994_bridgeMethods() throws Exception {
ReflectivePropertyAccessor accessor = new ReflectivePropertyAccessor();
StandardEvaluationContext context = new StandardEvaluationContext();
GenericImplementation target = new GenericImplementation();
accessor.write(context, target, "property", "1");
assertThat(target.value).isEqualTo(1);
TypedValue value = accessor.read(context, target, "property");
assertThat(value.getValue()).isEqualTo(1);
assertThat(value.getTypeDescriptor().getType()).isEqualTo(Integer.class);
assertThat(value.getTypeDescriptor().getAnnotations()).isNotEmpty();
}
use of cn.taketoday.expression.spel.support.ReflectivePropertyAccessor in project today-framework by TAKETODAY.
the class SpelReproTests method propertyAccessOnNullTarget_SPR5663.
@Test
void propertyAccessOnNullTarget_SPR5663() throws AccessException {
PropertyAccessor accessor = new ReflectivePropertyAccessor();
EvaluationContext context = TestScenarioCreator.getTestEvaluationContext();
assertThat(accessor.canRead(context, null, "abc")).isFalse();
assertThat(accessor.canWrite(context, null, "abc")).isFalse();
assertThatIllegalStateException().isThrownBy(() -> accessor.read(context, null, "abc"));
assertThatIllegalStateException().isThrownBy(() -> accessor.write(context, null, "abc", "foo"));
}
use of cn.taketoday.expression.spel.support.ReflectivePropertyAccessor in project today-framework by TAKETODAY.
the class SpelReproTests method SPR10162_onlyBridgeMethod.
@Test
void SPR10162_onlyBridgeMethod() throws Exception {
ReflectivePropertyAccessor accessor = new ReflectivePropertyAccessor();
StandardEvaluationContext context = new StandardEvaluationContext();
Object target = new OnlyBridgeMethod();
TypedValue value = accessor.read(context, target, "property");
assertThat(value.getValue()).isNull();
assertThat(value.getTypeDescriptor().getType()).isEqualTo(Integer.class);
}
Aggregations