### Question:
TCPConnectivity extends ConnectivityCapability { @Override public boolean supports(final SystemComponent requirement) { boolean supports = hasBasicSupport(requirement.getName(), requirement.getClassName()); if(supports) { String hostAddress = (String) requirement.getAttributes().get(HOST_ADDRESS); String hostName = (String) requirement.getAttributes().get(HOST_NAME); if(hostAddress!=null) { supports = hostAddress.equals(getValue(HOST_ADDRESS)); } else { supports = hostName.equalsIgnoreCase((String) getValue(HOST_NAME)); } } return supports; } TCPConnectivity();  TCPConnectivity(final String description); @Override boolean supports(final SystemComponent requirement); static final String IPv6_NIC; static final String IPv4_NIC; static final String HOST_ADDRESS; static final String HOST_NAME; static final String ID; }### Answer:
@Test public void testDoesNotSupportHostAddress() throws Exception { SystemComponent requirement = new SystemComponent(TCPConnectivity.ID); requirement.put(TCPConnectivity.HOST_ADDRESS, "127.0.0.1"); TCPConnectivity tcpConnectivity = new TCPConnectivity(); tcpConnectivity.define(TCPConnectivity.HOST_ADDRESS, "10.0.1.1"); Assert.assertFalse(tcpConnectivity.supports(requirement)); System.out.println(tcpConnectivity); System.out.println(requirement); }
@Test public void testSupportsHostAddress() throws Exception { SystemComponent requirement = new SystemComponent(TCPConnectivity.ID); requirement.put(TCPConnectivity.HOST_ADDRESS, "127.0.0.1"); TCPConnectivity tcpConnectivity = new TCPConnectivity(); tcpConnectivity.define(TCPConnectivity.HOST_ADDRESS, "127.0.0.1"); Assert.assertTrue(tcpConnectivity.supports(requirement)); }
@Test public void testSupportsHostName() throws Exception { SystemComponent requirement = new SystemComponent(TCPConnectivity.ID); requirement.put(TCPConnectivity.HOST_NAME, "mixed.case.name.net"); TCPConnectivity tcpConnectivity = new TCPConnectivity(); tcpConnectivity.define(TCPConnectivity.HOST_NAME, "MiXed.Case.Name.Net"); Assert.assertTrue(tcpConnectivity.supports(requirement)); }
@Test public void testDoesNotSupportHostName() throws Exception { SystemComponent requirement = new SystemComponent(TCPConnectivity.ID); requirement.put(TCPConnectivity.HOST_NAME, "some.name.net"); TCPConnectivity tcpConnectivity = new TCPConnectivity(); tcpConnectivity.define(TCPConnectivity.HOST_NAME, "some.other.name.net"); Assert.assertFalse(tcpConnectivity.supports(requirement)); }