@Test public void SPR10162_onlyBridgeMethod() throws Exception { ReflectivePropertyAccessor accessor = new ReflectivePropertyAccessor(); StandardEvaluationContext context = new StandardEvaluationContext(); Object target = new OnlyBridgeMethod(); TypedValue value = accessor.read(context, target, "property"); assertEquals(Integer.class, value.getTypeDescriptor().getType()); }
@Test public void SPR9994_bridgeMethods() throws Exception { ReflectivePropertyAccessor accessor = new ReflectivePropertyAccessor(); StandardEvaluationContext context = new StandardEvaluationContext(); Object target = new GenericImplementation(); TypedValue value = accessor.read(context, target, "property"); assertEquals(Integer.class, value.getTypeDescriptor().getType()); }
EvaluationContext ctx = new StandardEvaluationContext(t); assertTrue(rpa.canRead(ctx, t, "property")); assertEquals("hello",rpa.read(ctx, t, "property").getValue()); assertEquals("hello",rpa.read(ctx, t, "property").getValue()); // cached accessor used assertEquals(3,rpa.read(ctx, t, "field").getValue()); assertEquals(3,rpa.read(ctx, t, "field").getValue()); // cached accessor used assertEquals(3,rpa.read(ctx, t, "field2").getValue()); assertEquals(0,rpa.read(ctx, t, "field3").getValue()); assertEquals("doodoo",rpa.read(ctx, t, "property3").getValue()); assertEquals(0,rpa .read(ctx, t, "field3").getValue()); assertEquals(false,rpa.read(ctx, t, "property4").getValue()); assertTrue(rpa.canRead(ctx, t, "property4")); assertEquals("iD",rpa.read(ctx, t, "iD").getValue()); assertTrue(rpa.canRead(ctx, t, "iD")); assertEquals("id",rpa.read(ctx, t, "id").getValue()); assertTrue(rpa.canRead(ctx, t, "id")); assertEquals("ID",rpa.read(ctx, t, "ID").getValue()); assertTrue(rpa.canRead(ctx, t, "ID")); assertEquals("id",rpa.read(ctx, t, "Id").getValue()); assertTrue(rpa.canRead(ctx, t, "Id")); assertEquals("xyZ",rpa.read(ctx, t, "xyZ").getValue()); assertTrue(rpa.canRead(ctx, t, "xyZ"));
@Override public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException { if (target instanceof Message) { if (PAYLOAD.equals(name) || HEADERS.equals(name)) { return super.read(context, target, name); } else { return super.read(context, ((Message<?>)target).getHeaders(), name); } } return super.read(context, target, name); }