### Question:
ProtocolHandlerConfigurator { private synchronized boolean addProvider(String baseProtocolPackage, String... schemes) { trace(String.format("Configuring provider '%s' for custom protocol handlers %s",baseProtocolPackage,Arrays.asList(schemes))); List<String> providers = getProviders(); boolean needUpdate=!providers.contains(baseProtocolPackage); if(needUpdate) { packagesAdded.add(baseProtocolPackage); } trace( !needUpdate? "Custom protocol handler provider '%s' already configured.": "Registered custom protocol handler provider '%s'.", baseProtocolPackage); return needUpdate; } private  ProtocolHandlerConfigurator(); static boolean isSupported(String scheme); static URLStreamHandler getHandler(String scheme); static boolean addProvider(Class<T> handlerClass); static void reset();  }### Answer:
@Test public void testAddProvider$valid() throws Exception { assertThat(ProtocolHandlerConfigurator.addProvider(Handler.class),equalTo(true)); assertThat(ProtocolHandlerConfigurator.isSupported("net"),equalTo(true)); assertThat(ProtocolHandlerConfigurator.getHandler("net"),instanceOf(Handler.class)); }
@Test public void testAddProvider$repeated() throws Exception { ProtocolHandlerConfigurator.addProvider(Handler.class); assertThat(ProtocolHandlerConfigurator.isSupported("net"),equalTo(true)); assertThat(ProtocolHandlerConfigurator.addProvider(Handler.class),equalTo(false)); assertThat(ProtocolHandlerConfigurator.isSupported("net"),equalTo(true)); }
@Test(expected=IllegalArgumentException.class) public void testAddProvider$invalid() throws Exception { ProtocolHandlerConfigurator.addProvider(InvalidHandler.class); }