UserAgentImpl implements UserAgent, ProviderScanner { static void relayProperties(final Properties properties, final Set<String> propertyNames, final List<String> destinationCommand) { for (final String propertyName : propertyNames) { final String propertyValue = properties.getProperty(propertyName); if (propertyValue != null) { destinationCommand.add("-D" + propertyName + "=" + propertyValue); } } } UserAgentImpl();   UserAgentImpl(final TestableProcessFactory processFactory, final Provider provider, final List<Provider> candidateProviders); @Override Provider findCompatibleProvider(); @Override Provider findCompatibleProvider(final String userAgentProvider); @Override Map<Provider, List<String>> getUnmetProviderRequirements(); @Override boolean hasCompatibleProvider(); @Override boolean hasCompatibleProvider(final String userAgentProvider); @Override AuthorizationResponse requestAuthorizationCode(final URI authorizationEndpoint, final URI redirectUri); static StringBuilder buildUnsupportedMessage(Map<Provider, List<String>> unmetRequirements); static void describeUnmetRequirements(final Map<Provider, List<String>> unmetRequirements, final StringBuilder destination);  }
@Test public void relayProperties_typical() throws Exception { final HashSet<String> propertyNames = new HashSet<String>(Arrays.asList("http.proxyHost", "http.proxyPort")); final Properties properties = new Properties(); properties.setProperty("http.proxyHost", "192.0.2.42"); final List<String> commands = new ArrayList<String>(); UserAgentImpl.relayProperties(properties, propertyNames, commands); Assert.assertEquals(1, commands.size()); Assert.assertEquals("-Dhttp.proxyHost=192.0.2.42", commands.get(0)); }
@Test public void relayProperties_noneSet() throws Exception { final HashSet<String> propertyNames = new HashSet<String>(Arrays.asList("http.proxyHost", "http.proxyPort")); final Properties properties = new Properties(); final List<String> commands = new ArrayList<String>(); UserAgentImpl.relayProperties(properties, propertyNames, commands); Assert.assertEquals(0, commands.size()); }