### Question:
NameResolverProvider extends NameResolver.Factory { public static NameResolver.Factory asFactory() { return factory; }  static List<NameResolverProvider> providers(); static NameResolver.Factory asFactory(); @SuppressWarnings("unused") // Avoids outside callers accidentally depending on the super class.
  static final Attributes.Key<Integer> PARAMS_DEFAULT_PORT; }### Answer:
@Test public void getDefaultScheme_noProvider() { List<NameResolverProvider> providers = Collections.<NameResolverProvider>emptyList(); NameResolver.Factory factory = NameResolverProvider.asFactory(providers); try { factory.getDefaultScheme(); fail("Expected exception"); } catch (RuntimeException ex) { assertTrue(ex.toString(), ex.getMessage().contains("No NameResolverProviders found")); } }
@Test public void newNameResolver_providerReturnsNull() { List<NameResolverProvider> providers = Collections.<NameResolverProvider>singletonList( new BaseProvider(true, 5) { @Override public NameResolver newNameResolver(URI passedUri, Attributes passedAttributes) { assertSame(uri, passedUri); assertSame(attributes, passedAttributes); return null; } }); assertNull(NameResolverProvider.asFactory(providers).newNameResolver(uri, attributes)); }
@Test public void newNameResolver_noProvider() { List<NameResolverProvider> providers = Collections.<NameResolverProvider>emptyList(); NameResolver.Factory factory = NameResolverProvider.asFactory(providers); try { factory.newNameResolver(uri, attributes); fail("Expected exception"); } catch (RuntimeException ex) { assertTrue(ex.toString(), ex.getMessage().contains("No NameResolverProviders found")); } }