ExternalResources { public int getInteger(@IntegerRes int resId) throws NotFoundException { String key = getApplicationResourceEntryName(resId); if (null != key) { Resource resource = resources.get(key); if (null != resource && null != resource.getAsInt()) { return resource.getAsInt(); } } throw new NotFoundException("Integer resource with resId: " + resId); } private  ExternalResources(@NonNull Context context, @NonNull Converter converter,
      @NonNull Url url, @NonNull Options options, @Cache.Policy int cachePolicy,
      @Logger.Level int logLevel, @NonNull Resources defaultResources,
      @Nullable OnExternalResourcesLoadFailedListener failedListener,
      boolean useApplicationResources); @SuppressWarnings("ConstantConditions") static ExternalResources initialize(
      @NonNull Context context, Url url); @SuppressWarnings("ConstantConditions") static ExternalResources initialize(
      @NonNull Context context, @NonNull String baseUrl); @SuppressWarnings("ConstantConditions") static ExternalResources initialize(
      @NonNull ExternalResources externalResources); static ExternalResources getInstance(); void onConfigurationChanged(Configuration newConfig); boolean getBoolean(@BoolRes int resId); boolean getBoolean(@NonNull String key); @ColorInt int getColor(@ColorRes int resId); @ColorInt int getColor(@NonNull String key); float getDimension(@DimenRes int resId); float getDimension(@NonNull String key); String getString(@StringRes int resId); String getString(@NonNull String key); String getString(@StringRes int resId, Object... formatArgs); String getString(@NonNull String key, Object... formatArgs); String[] getStringArray(@ArrayRes int resId); String[] getStringArray(@NonNull String key); int getInteger(@IntegerRes int resId); int getInteger(@NonNull String key); int[] getIntArray(@ArrayRes int resId); int[] getIntArray(@NonNull String key); void register(OnExternalResourcesChangeListener listener); void unregister(OnExternalResourcesChangeListener listener); void removeFailListener(); static final String TAG; }
@Test public void testGetInteger() throws Exception { assertEquals(75, externalResources.getInteger("max_speed")); assertEquals(5000, externalResources.getInteger("network_connection_speed")); assertEquals(5000, externalResources.getInteger(R.integer.network_connection_speed)); }
@Test(expected = NotFoundException.class) public void testGetIntegerNotFound() throws Exception { externalResources.getInteger("unknown"); }
@Test(expected = NotFoundException.class) public void testGetResIntegerNotFound() throws Exception { externalResources.getInteger(0); }