### Question:
MessageELResolver extends ELResolver { @Override public Object getValue(ELContext context, Object base, Object property) { if ((base == null) && PROPERTY_MSG.equals(property)) { context.setPropertyResolved(true); return bundle; } else if (base instanceof MessageBundle) { String text = bundle.getMessages().get(property.toString()); if (text == null) { context.setPropertyResolved(true); return null; } List<Object> properties = null; try { properties = pushCurrentProperty(context, property); context.setPropertyResolved(false); return expressions.parse(text, Object.class).getValue(context); } finally { popProperty(properties); context.setPropertyResolved(true); } } return null; } MessageELResolver(Expressions expressions, MessageBundle bundle); @Override Class<?> getCommonPropertyType(ELContext context, Object base); @Override Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context,
      Object base); @Override Class<?> getType(ELContext context, Object base, Object property); @Override Object getValue(ELContext context, Object base, Object property); @Override boolean isReadOnly(ELContext context, Object base, Object property); @Override void setValue(ELContext context, Object base, Object property, Object value); static final String PROPERTY_MSG; }### Answer:
@Test public void basicExpression() { assertEquals("world", expressions.parse("${Msg.hello}", String.class).getValue(context)); }
@Test public void nullForMissingProperty() { assertNull(expressions.parse("${Msg.notThere}", Object.class).getValue(context)); }
@Test public void innerEvaluation() { assertEquals(2, expressions.parse("${Msg.number}", Integer.class).getValue(context)); }
@Test public void recursiveEvaluation() { assertEquals("world 2", expressions.parse("${Msg.concat}", String.class).getValue(context)); }
@Test public void multiLevelRecursiveEvaluation() { assertEquals("world 2 world 2", expressions.parse("${Msg.multiLevel}", String.class).getValue(context)); }
@Test(expected = ELException.class) public void failsInsteadOfInfiniteRecursion() { expressions.parse("${Msg.recurse}", String.class).getValue(context); }
@Test(expected = ELException.class) public void failsInsteadOfMutualInfiniteRecursion() { expressions.parse("${Msg.mutual1}", String.class).getValue(context); }