### Question:
MessageSubstituter implements Substituter { public void addSubstitutions(Substitutions substituter, GadgetContext context, GadgetSpec spec) throws GadgetException { MessageBundle bundle = messageBundleFactory.getBundle(spec, context.getLocale(), context.getIgnoreCache(), context.getContainer(), context.getView()); substituter.addSubstitutions(Substitutions.Type.MESSAGE, bundle.getMessages()); } @Inject  MessageSubstituter(MessageBundleFactory messageBundleFactory); void addSubstitutions(Substitutions substituter, GadgetContext context, GadgetSpec spec);  }### Answer:
@Test public void testMessageReplacements() throws Exception { String xml = "<Module>" + " <ModulePrefs title=''>" + " <Locale>" + " <msg name='foo'>bar</msg>" + " <msg name='bar'>baz</msg>" + " </Locale>" + " </ModulePrefs>" + " <Content />" + "</Module>"; Substitutions substitutions = new Substitutions(); substituter.addSubstitutions(substitutions, context, new GadgetSpec(Uri.parse("#"), xml)); assertEquals("bar", substitutions.getSubstitution(Type.MESSAGE, "foo")); assertEquals("baz", substitutions.getSubstitution(Type.MESSAGE, "bar")); }