### Question:
MessageConveyor implements IMessageConveyor { public <E extends Enum<?>> String getMessage(E key, Object... args) throws MessageConveyorException { String declararingClassName = key.getDeclaringClass().getName(); CAL10NResourceBundle rb = cache.get(declararingClassName); if (rb == null || rb.hasChanged()) { rb = lookup(key); cache.put(declararingClassName, rb); } String keyAsStr = key.toString(); String value = rb.getString(keyAsStr); if (value == null) { return "No key found for " + keyAsStr; } else { if (args == null || args.length == 0) { return value; } else { return MessageFormat.format(value, args); } } } MessageConveyor(Locale locale); String getMessage(E key, Object... args); String getMessage(MessageParameterObj mpo);  }### Answer:
@Test public void smoke_EN() { MessageConveyor rbbmc = new MessageConveyor(Locale.UK); String val; val = rbbmc.getMessage(Colors.BLUE); assertEquals("violets are blue", val); val = rbbmc.getMessage(Colors.GREEN, "apples"); assertEquals("apples are green", val); }
@Test public void nestedEnum_EN() { MessageConveyor rbbmc = new MessageConveyor(Locale.UK); String val; val = rbbmc.getMessage(Colors.RED); assertEquals("roses are red", val); val = rbbmc.getMessage(OtherColors.RED); assertEquals("roses are red", val); val = rbbmc.getMessage(OtherColors.BLUE); assertEquals("violets are blue", val); }
@Test public void smoke_FR() { MessageConveyor rbbmc = new MessageConveyor(Locale.FRANCE); String val; val = rbbmc.getMessage(Colors.BLUE); assertEquals("les violettes sont bleues", val); val = rbbmc.getMessage(Colors.GREEN, "pommes"); assertEquals("les pommes sont verts", val); }
@Test public void mpo() { MessageConveyor rbbmc = new MessageConveyor(Locale.UK); MessageParameterObj mpo; String val; mpo = new MessageParameterObj(Colors.BLUE); val = rbbmc.getMessage(mpo); assertEquals("violets are blue", val); mpo = new MessageParameterObj(Colors.GREEN, "apples"); val = rbbmc.getMessage(mpo); assertEquals("apples are green", val); }
@Test public void failedRBLookup() { MessageConveyor mc = new MessageConveyor(Locale.CHINA); try { mc.getMessage(Colors.BLUE); fail("missing exception"); } catch (MessageConveyorException e) { assertEquals( "Failed to locate resource bundle [colors] for locale [zh_CN] for enum type [ch.qos.cal10n.sample.Colors]", e.getMessage()); } }
@Test public void minimal() { MessageConveyor mc = new MessageConveyor(Locale.ENGLISH); assertEquals("A", mc.getMessage(Minimal.A)); }