NullProtectingProxyInfoProvider implements ProxyInfoProvider { @Override public ProxyInfo getProxyInfo(String protocol) { if ((protocol == null) || (this.proxyInfo == null) || protocol.equalsIgnoreCase(this.proxyInfo.getType())) { return this.proxyInfo; } else { return null; } } NullProtectingProxyInfoProvider(ProxyInfo proxyInfo); @Override ProxyInfo getProxyInfo(String protocol);  }
@Test public void getProxyInfoNullProtocol() { assertSame(this.proxyInfo, this.proxyInfoProvider.getProxyInfo(null)); }
@Test public void getProxyInfoNullProxy() { assertNull(new NullProtectingProxyInfoProvider(null).getProxyInfo("foo")); }
@Test public void getProxyInfoMatchingProtocol() { when(this.proxyInfo.getType()).thenReturn("FOO"); assertSame(this.proxyInfo, this.proxyInfoProvider.getProxyInfo("foo")); }
@Test public void getProxyInfoNonMatchingProtocol() { when(this.proxyInfo.getType()).thenReturn("FOO"); assertNull(this.proxyInfoProvider.getProxyInfo("bar")); }