EvaluationContext ctx = new StandardEvaluationContext(t);
// assertTrue(rpr.canRead(ctx, t, "property"));
// assertEquals("hello",rpr.read(ctx, t, "property").getValue());
// assertEquals("hello",rpr.read(ctx, t, "property").getValue()); // cached accessor used
PropertyAccessor optA = rpr.createOptimalAccessor(ctx, t, "property");
assertTrue(optA.canRead(ctx, t, "property"));
assertFalse(optA.canRead(ctx, t, "property2"));
try {
optA.canWrite(ctx, t, "property");
fail();
}
catch (UnsupportedOperationException uoe) {
// success
}
try {
optA.canWrite(ctx, t, "property2");
fail();
}
catch (UnsupportedOperationException uoe) {
// success
}
assertEquals("hello",optA.read(ctx, t, "property").getValue());
assertEquals("hello",optA.read(ctx, t, "property").getValue()); // cached accessor used
try {
optA.getSpecificTargetClasses();
fail();
}
catch (UnsupportedOperationException uoe) {
// success
}
try {
optA.write(ctx,t,"property",null);
fail();
}
catch (UnsupportedOperationException uoe) {
// success
}
optA = rpr.createOptimalAccessor(ctx, t, "field");
assertTrue(optA.canRead(ctx, t, "field"));
assertFalse(optA.canRead(ctx, t, "field2"));
try {
optA.canWrite(ctx, t, "field");
fail();
}
catch (UnsupportedOperationException uoe) {
// success
}
try {
optA.canWrite(ctx, t, "field2");
fail();
}
catch (UnsupportedOperationException uoe) {
// success
}
assertEquals(3,optA.read(ctx, t, "field").getValue());
assertEquals(3,optA.read(ctx, t, "field").getValue()); // cached accessor used
try {
optA.getSpecificTargetClasses();
fail();
}
catch (UnsupportedOperationException uoe) {
// success
}
try {
optA.write(ctx,t,"field",null);
fail();
}
catch (UnsupportedOperationException uoe) {
// success
}