PrefixContext implements ImmutableContext { @Override public int getInt(String key, int defaultValue) { return configuration.getInt(prefix + key, defaultValue); } PrefixContext(Configuration configuration, String prefix); @Override String getString(String key); @Override String getString(String key, String defaultValue); @Override long getLong(String key, long defaultValue); @Override int getInt(String key, int defaultValue); @Override boolean getBoolean(String key, boolean defaultValue); Configuration getConfiguration(); @Override Iterator<Map.Entry<String, String>> iterator();  }
@Test public void testGetInt() { Configuration configuration = new Configuration(); configuration.set("p.testkey", "123"); PrefixContext context = new PrefixContext(configuration, "p."); assertEquals(123, context.getInt("testkey", 456)); assertEquals(456, context.getInt("wrongKey", 456)); }