CodenvyDockerServerEvaluationStrategy extends ServerEvaluationStrategy { @Override protected Map<String, String> getInternalAddressesAndPorts( ContainerInfo containerInfo, String internalHost) { Map<String, List<PortBinding>> portBindings = containerInfo.getNetworkSettings().getPorts(); return getExposedPortsToAddressPorts(internalHost, portBindings); }    }
@Test public void shouldReturnEmptyMapOnRetrievalOfInternalAddressesIfNoPortExposed() throws Exception { assertTrue(strategy.getInternalAddressesAndPorts(containerInfo, HOST).isEmpty()); }
@Test public void shouldUseProvidedInternalHostOnRetrievalOfInternalAddresses() throws Exception { Map<String, List<PortBinding>> exposedPorts = new HashMap<>(); exposedPorts.put( "8080/tcp", singletonList(new PortBinding().withHostIp("127.0.0.1").withHostPort("32789"))); exposedPorts.put( "9090/udp", singletonList(new PortBinding().withHostIp("192.168.0.1").withHostPort("20000"))); when(networkSettings.getPorts()).thenReturn(exposedPorts); Map<String, String> internalAddressesAndPorts = strategy.getInternalAddressesAndPorts(containerInfo, HOST); for (Map.Entry<String, List<PortBinding>> entry : exposedPorts.entrySet()) { assertEquals( internalAddressesAndPorts.get(entry.getKey()), HOST + ":" + entry.getValue().get(0).getHostPort()); } }